上一页 1 ··· 4 5 6 7 8 9 10 11 下一页
摘要: 题目描述 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。 /* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(i 阅读全文
posted @ 2020-02-21 20:52 清心lh 阅读(132) 评论(0) 推荐(0)
摘要: 题目描述 输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 输入描述: 输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。 解题思路: /*1.求的所有可 阅读全文
posted @ 2020-02-21 20:50 清心lh 阅读(251) 评论(0) 推荐(0)
摘要: 题目描述 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。如果不存在则输出0。 class Solution { public: int MoreThanHa 阅读全文
posted @ 2020-02-21 20:46 清心lh 阅读(155) 评论(0) 推荐(0)
摘要: 题目描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。 class Solution { public: vector<int> GetLeastNumbers_Solution(vector<int> input, in 阅读全文
posted @ 2020-02-21 20:44 清心lh 阅读(117) 评论(0) 推荐(0)
摘要: 加&表示引用。引用的意思就是起个别名,但还在用原来的变量。 例如: int a=1;int &b=a; //b是a的引用,加后对b操作就是对a操作!b=2;cout<<a<<endl; 结果是 2.不加就不是引用。 int a=1;int b=a; b=2;cout<<a<<endl; 结果是 1. 阅读全文
posted @ 2020-02-21 10:43 清心lh 阅读(1394) 评论(0) 推荐(0)
摘要: 将一张图片分成100等份: # -*- coding: utf-8 -*- from PIL import Image filename = r'F:\bishe\data\file\label_139.png' img = Image.open(filename) size = img.size 阅读全文
posted @ 2020-02-15 19:16 清心lh 阅读(6714) 评论(0) 推荐(0)
摘要: 代码: #集中不同的优化方式 import torch import torch.utils.data as Data import torch.nn.functional as F from torch.autograd import Variable import matplotlib.pypl 阅读全文
posted @ 2020-02-12 17:34 清心lh 阅读(687) 评论(0) 推荐(0)
摘要: 代码: #进行批训练 import torch import torch.utils.data as Data BATCH_SIZE = 5 #每批5个数据 if __name__ == '__main__': x = torch.linspace(1, 10, 10) #x是从1到10共10个数据 阅读全文
posted @ 2020-02-12 17:32 清心lh 阅读(1137) 评论(0) 推荐(0)
摘要: 代码如下: #实现网络的保存和提取 import torch from torch.autograd import Variable import matplotlib.pyplot as plt #设置随机种子实现结果复现,在神经网络中,参数默认是进行随机初始化的。 # 不同的初始化参数往往会导致 阅读全文
posted @ 2020-02-12 17:30 清心lh 阅读(1854) 评论(0) 推荐(0)
摘要: 完整代码 #实现分类 import torch import torch.nn.functional as F from torch.autograd import Variable import matplotlib.pyplot as plt import torch.optim as opti 阅读全文
posted @ 2020-02-10 14:48 清心lh 阅读(4490) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 下一页