上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页
摘要: 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 如果输入是负数:return false; 输入正数:如121, return true; 第一遍写法直接判断数字第一位和最后一位是否相等: 然后发现有更简单的代码: 阅读全文
posted @ 2019-07-21 17:34 卷积 阅读(330) 评论(0) 推荐(0) 编辑
摘要: RuntimeError: bool value of Tensor with more than one value is ambiguous 运行下面这段代码的时候出错了,后来网上搜说改成 if w1.grad is not None: 可以通过。 阅读全文
posted @ 2019-04-24 15:47 卷积 阅读(4436) 评论(0) 推荐(0) 编辑
摘要: 参考:https://pytorch-cn.readthedocs.io/zh/latest/torchvision/torchvision-transform/ 1.pytorch torchvision transform 对PIL.Image进行变换: 2. class torchvision 阅读全文
posted @ 2019-04-22 10:30 卷积 阅读(5458) 评论(0) 推荐(0) 编辑
摘要: 参考: http://www.runoob.com/python/python-func-isinstance.html isinstance 用来判断一个对象是否是一个已知的类型。 用法: isinstance(object, classinfo) 参数: object--实例对象, classi 阅读全文
posted @ 2019-04-20 11:09 卷积 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 实现需要以下两点: 1.跟踪树的大小(树的元素个数)。 2.将小树链接到大树上。 代码来自红书:算法(第4版),很简洁。 阅读全文
posted @ 2019-04-13 22:27 卷积 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 2.新的迭代器 的接口为Iterator类 3.想让自己定义的类支持Foreach循环,需要继承Interable类 阅读全文
posted @ 2019-04-03 21:06 卷积 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 今天做笔试的时候忘了全排列怎么写。依稀记得有个next_permutation()。 1. 后来自己用递归实现了一下数组的全排列。 2. 以及调用next_permuation()函数,在algorithm函数中,刷题还是太少(- _-D)。 3. 使用深度优先 阅读全文
posted @ 2019-03-27 22:14 卷积 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 在使用memcpy直接拷贝到temp地址中,出现段错误。 stackoverflow搜说是temp没有分配空间, 是一个空指针,所以会出现段错误。 https://stackoverflow.com/questions/26793463/segmentation-fault-when-using-m 阅读全文
posted @ 2019-03-09 21:15 卷积 阅读(258) 评论(0) 推荐(0) 编辑
摘要: unsigned char* getDirectionGray( unsigned char** ptrCenterRow, int j) { unsigned char p[4]; //如果修改成*p则出现段错误,还没搞懂 p[0] = abs(ptrCenterRow[-1][(j-1)] -ptrCenterRow[0][j]) + ... 阅读全文
posted @ 2019-03-08 11:57 卷积 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 一道面试题引发的问题,首先要知道[]的优先级高于*,题目: char **p,a[6][8]; 问p=a是否会导致程序在以后出现问题?为什么? 阅读全文
posted @ 2019-03-04 17:08 卷积 阅读(1134) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页