代码随想录打卡 第十五天

如何使用 Conda 安装 Qiskit(详细教程) 本文介绍了使用conda安装Qiskit量子计算工具包的完整流程。首先创建Python 3.10的conda虚拟环境(qiskit_env),然后安装Qiskit核心包及可视化组件(注意Mac用户的安装命令差异)。接着注册IPython内核并测试环境,通过量子电路创建与可视化演示验证安装成功。该教程为量子计算开发提供了简洁的环境配置指南,适合研究者和开发者快速搭建Qiskit开发环境。 阅读详情

110 平衡二叉树

class Solution {
public:
    int high(TreeNode* node){
        int result;
        if(node == nullptr) return 0;

        int left_high = high(node->left);
        if(left_high == -1) return -1;

        int right_high = high(node->right);
        if(right_high == -1) return -1;

        if(right_high - left_high > 1 || right_high - left_high < -1) return -1;
        else result = 1 + max(right_high,left_high);
        
        return result;
    }
    bool isBalanced(TreeNode* root) {
        int result = high(root);
        if(result == -1) return false;
        else return true;
    }
};

257 二叉树的所有路径

class Solution {
public:
    void scam(TreeNode* node,vector<int>& path,vector<string>& result){
        path.push_back(node->val);
        if(node->left == nullptr && node->right == nullptr){
            string sPath;;
            for (int i = 0; i < path.size() - 1; i++){
                sPath +=  to_string(path[i]);
                sPath += "->";
            }
            sPath +=  to_string(path[path.size() - 1]);
            result.push_back(sPath);
            return;
        }

        if(node->left){
            scam(node->left,path,result);
            path.pop_back();
        }
        if(node->right){
            scam(node->right,path,result);
            path.pop_back();
        }
    }
    vector<string> binaryTreePaths(TreeNode* root) {
        vector<string> result;
        vector<int> path;
        if (root == NULL) return result;
        scam(root, path, result);
        return result;
    }
};

404 左叶子之和

class Solution {
public:
    void scam(TreeNode* node,int& result){
        if(node->left == nullptr && node->right == nullptr) return;
        
        if(node->left) scam(node->left,result);
        if(node->right) scam(node->right,result);

        if(node->left != nullptr && node->left->left == nullptr && node->left->right == nullptr){
            result += node->left->val;
        }
    }
    int sumOfLeftLeaves(TreeNode* root) {
        int result = 0;
        scam(root,result);
        return result;
    }
};

222 完全二叉树的节点个数

class Solution {
public:
    void scam(TreeNode* node,int& count){
        if(node == nullptr) return;
        
        if(node->left) scam(node->left,count);
        if(node->right) scam(node->right,count);

        count++;
    }
    int countNodes(TreeNode* root) {
        int count = 0;
        scam(root,count);
        return count;
    }
};

论文阅读:ICLR 2023 FINE-TUNING ALIGNED LANGUAGE MODELS COMPROMISES SAFETY, EVEN WHEN USERS DO NOT INTEND 对大型语言模型(LLMs)进行微调以适应特定用例通常涉及对预训练的LLMs进行进一步的定制。Meta公开发布Llama模型和OpenAI的API允许在自定义数据集上微调GPT-3.5 Turbo,也鼓励这种做法。但是,这种自定义微调与安全成本有何关联?我们注意到,尽管现有的安全对齐基础设施可以在推理时限制LLMs的有害行为,但它们并未涵盖将微调权限扩展到最终用户时的安全风险。我们的红队研究发现,即使是只有几个设计有敌意的训练示例进行微调,也可以破坏LLMs的安全对齐。 阅读详情

相关推荐

osgEarth shapefile矢量生成三维模型案例 2.boston.earth

osgEarth shapefile矢量生成三维模型案例 2.boston.earth 波士顿城市建筑、路灯、公园、道路shp矢量生成三维模型案例。

qq_24934183的博客 3552

代码随想录打卡第十五天

【代码】代码随想录打卡第十五天。

m0_60633015的博客 179

技术解析:ChangeFormer——基于Transformer的孪生网络在遥感变化检测中的创新应用

本文深入解析了ChangeFormer模型在遥感变化检测中的创新应用,该模型基于Transformer架构和孪生网络(Siamese Network),显著提升了变化检测的精度和效率。通过详细的技术实现和实战经验分享,展示了其在建筑物变化、森林监测等场景中的卓越表现,为相关领域的研究和应用提供了有力工具。

weixin_29102619的博客 503

代码随想录算法训练营第60期第十五天打卡

哈哈,怎么说呢?今天的题目说难也不算难,说简单但也绝对不简单,我想告诉大家的是,无论难还是简单,大家都务必坚持下去,以后或许越来越难,其实今天已经涉及到回溯,在后面会有一个专门的章节来讲回溯算法,在后面的图论里面也会有涉及,大家务必打好基础,其实一刷代码随想录你要看到一个题目要有自己的想法,先不着急上手写代码,这个其实一刷写不出来代码我感觉很正常,多学多刷,代码随想录一遍肯定不够我感觉要三遍以上才能真正理解这些算法,大家加油,我们明天还是二叉树章节。明天见!

2401_83782806的博客 744

QEMU pcie config空间访问机制

而pci_host_conf/data_le_ops的定义是在hw/pci/pci-host.c里,对于0xCF8端口的处理,因为是地址选通,所以只需要在write的时候记录、read的时候返回记录的值即可。而pci_host_config_write/read_common接口,在前256Bconfig空间的模拟中,也同样是会调用这个接口,所以后续的处理都是一样的。这是真实的硬件设计,而对于QEMU+KVM的虚机场景,显然是要基于硬件实现和虚拟化的需求设计虚机访问config空间的完整流程。

leiyanjie8995的博客 1959

【机械视觉】Halcon—【二、Halcon算子全面介绍(超详细版)】

Halcon 的算子(operators)按照功能被系统性地划分为多个类别,官方文档中目前(Halcon 22.11 版本)共有 19 个主分类,每个主分类下还有若干子分类。 本人在此对这19个分类的常用核心算子进行了一系列的总结,且本人在文章最后还总结了一些案例经验。 注意: ​​​​​​​跨分类调用:某些算子可能在多个分类中,但官方文档中会明确其主分类。 例如: read_image(文件操作)常被其他分类(如图像处理)的示例调用,但其核心功能是文件读取。

qq_3517289697的博客 3927

代码随想录打卡第十五天 二叉树

使用递归时没考虑右子树的左子树比根节点小的情况。看了题解,知道二叉搜索树中序遍历的特性,知道特性之后使用中序遍历就简单了很多。针对卡哥说的如果存在比long.min_value更小的情况,使用pre节点记录上一个节点也时不错的思路。如果两个节点都为空,合并结果也为空,直接返回空。如果都不为空,则使用val的和构造新节点,如果只有一个为空吗,则返回另一个节点。找到最大的元素,然后左边元素递归构造左子树,右边元素递归构造右子树,注意下标范围。层序遍历秒了,递归采用了二叉搜索树的特型,也是不错的递归思路。

weixin_47742046的博客 340

PX4从放弃到精通(十一):混控及PWM输出

文章目录前言一、混控脚本二、使用步骤1.引入库2.读入数据总结 前言 一个人可以走的更快,一群人才能走的更远,交流学习加qq:2096723956 更多保姆级PX4+ROS学习视频:https://b23.tv/ZeUDKqy 分享知识,传递正能量,如有疏漏或不当之处,恳请指出. 一、混控脚本 混控脚本定义了不同 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入库 代码如下(示例): import numpy as np import pand

超维空间科技的博客 1万+

3.12代码随想录第十五天打卡

c++

2401_87843408的博客 710

仿真模型简单介绍

同时,各种以伯克利的Spice仿真程序的算法为核心的商用Spice电路仿真工具也随之产生,运行在PC和UNIX平台,许多都是基于原始的SPICE2G6版的源代码,这是一个公开发表的版本,它们都在Spice的基础上做了很多实用化的工作,比较常见的Spice仿真软件有HSpice、Pspice、Spectre、Tspice、SmartSpcie、IsSpice等,虽然它们的核心算法雷同,但仿真速度、精度和收敛性却不一样,其中以Synopsys公司的Hspice和Cadence公司的Pspice最为著名。...

小幽余生不加糖 8013

【Codecs系列】x265编码器(十二):子像素运动搜索

在基于块运动补偿的视频编码框架中,运动搜索是最为重要的环节之一,同时也是编码端最为耗时的模块。运动搜索包括整像素运动搜索和子像素运动搜索,其中整像素运动搜索已经有很多快速算法,比如经典的三步搜索法、菱形搜索、六边形搜索以及TZSearch等等;但子像素搜索的快速算法却比较少,本文主要讲解x265编码器中的子像素搜索方法以及相关的快速搜索方法。

CSDN明星博主,认证博客专家,视频、Matlab领域优质创作者。 757

代码随想录训练营打卡第十五天

递归别细想, 一去想步骤就绕不出来了。递归 回溯 前序遍历。

yhxzcsq的博客 214

Visual Studio调试技巧与实用方法总结(实战经验分享)

本文根据多年的项目实战经验,详细介绍一些Visual Studio常用的高效调试手段与技巧。

dvlinker的技术专栏 3万+

代码随想录算法训练营第十五天打卡

学习二叉树好几天了,但是递归法还是一看就会一写就废。

qq_50649633的博客 148

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

代码随想录算法训练营第十五天|LeetCode110.平衡二叉树、LeetCode257.二叉树的所有路径、LeetCode404.左叶子之和、LeetCode222.完全二叉树的节点个数

打卡代码随想录算法训练营第49期第十五天o( ̄▽ ̄)d首先十分推荐学算法的同学可以先了解一下代码随想录,可以在B站。

tancxiaohei23的博客 553

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

代码随想录打卡第十五天|二叉树102.226.101

代码随想录打卡

weixin_45783266的博客 201

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

代码随想录打卡第十五天 | 二叉树2 层序遍历 | leetcode226&101

处理顺序:压入root 队列元素:1取出front,back, pop_front, pop_back(需先对队列判空,因为队列只有一个元素时,pop_front之后队列已空,不能使用pop_back),比较front和back,相等为空continue,不等返回false;相等不为空,分别push_front,push_back;//队列元素2,2,2,2(

weixin_43364099的博客 1038

代码随想录打卡第十五天|226翻转二叉树 ● 101.对称二叉树 2

翻转 对称二叉树

weixin_44925329的博客 164

代码随想录第十五天打卡|层序遍历 10 , 226.翻转二叉树,101.对称二叉树 2

没想到两个一起秒了原来可以两个同时递归。

2303_79574965的博客 411

代码随想录训练营第十五天打卡| 层序遍历 226.翻转二叉树 101. 对称二叉树

(想象一个二叉树用中序遍历翻转,当根节点的左子树翻转完了,开始进行根节点的左右子树进行翻转,左子树成为右子树,右子树成为左子树,之后进行根节点右子树的翻转,而此时的右子树是之前已经翻转好的左子树,此时再进行一次翻转,而真正要翻转的右子树此时已经成为根节点的左子树以为已经被翻转过了而不再处理,从而导致错误)核心都是掌握对称逻辑,也就是判断左孩子的左子树与右孩子的右子树是否对称以及左孩子的右子树以及右孩子的左子树是否对称。2.迭代法,以后序遍历为例(实际是后序遍历的逆序,对应的前序遍历只需要调换相应语句顺序)

m0_72484482的博客 426

代码随想录算法训练营第十五天打卡| 102 二叉树的层序遍历、226 翻转二叉树、101 对称二叉树

(即逐层地,从左到右访问所有节点)。,翻转这棵二叉树,并返回其根节点。题目描述:给你一棵二叉树的根节点。题目描述:给你一个二叉树的根节点。题目描述:给你二叉树的根节点。, 检查它是否轴对称。

wwwwwyyrr的博客 116

Amber-Leedcode-Java-代码随想录打卡第十五天 |● 层序遍历 10 ● 226.翻转二叉树 ● 101.对称二叉树

层序遍历待更新。

avery66666的博客 445

15.代码随想录算法训练营第十五天|(递归)110. 平衡二叉树,257. 二叉树的所有路径*,404. 左叶子之和,222.完全二叉树的节点个数[打卡自用]

力扣算法

LXY999222的博客 610

代码随想录算法训练营第十五天

今天主要是复习了二叉搜索树相关的概念.

岁岁安的博客 1188

代码随想录算法训练营总结篇

水一篇总结

岁岁安的博客 380

代码随想录算法训练营第四十天

本文主要介绍了LeetCode中两道关于回文子串和回文子序列的题目:647. 回文子串和516. 最长回文子序列。对于647题,通过动态规划的方法,统计字符串中所有回文子串的数量,时间复杂度为O(n^2),空间复杂度为O(n^2)。对于516题,同样使用动态规划,找出字符串中最长的回文子序列长度,时间复杂度为O(n^2),空间复杂度为O(n^2)。文章还总结了动态规划在解决各类问题中的应用,包括斐波那契数列、背包问题、股票交易等,并提供了往期打卡的链接。

岁岁安的博客 1093
上一篇: 代码随想录打卡 第十四天
下一篇: 代码随想录 打卡第十六天
WWW6526
博客等级 码龄7年 0粉丝 51原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值