
python
musenh
这个作者很懒,什么都没留下…
展开
-
错误集合
最近在学神经网络编程,跑程序时遇到了一些基础错误:TabError: inconsistent use of tabs and spaces in indentation一般是tab键和空格键使用不统一,要将程序前面的缩进统一改为tab或者相同数量的空格RuntimeError: input must have 3 dimensions, got 5这里涉及到维度的问题,因为我训练的神经网...原创 2020-02-07 11:09:43 · 7275 阅读 · 0 评论 -
pytroch常用函数
import torchimport torch.nn.functional as Fimport mathn1 = torch.nn.Linear(2,4)input1 = torch.randn(3,2)input2 = torch.randn(2,3)list1 = []out1 = n1(input1)out2 = F.relu(n1(input1))print('ou...原创 2020-01-21 10:16:52 · 203 阅读 · 0 评论 -
二分查找
输入:有序的元素列表输出:如果存在,返回位置如果不存在,返回null使用二分查找的算法复杂度为log(n)(以2为底)def mid_search (list,itme): low = 0 high = len(list) - 1 while low <= high: mid =int( (low + high) / 2 ) //索引必须是整数,...原创 2019-07-21 11:32:31 · 76 阅读 · 0 评论 -
算法图解——选择排序
时间复杂度为n的平方每次先找出最小值,添加到新的数组中,从大到小同理原创 2019-07-22 11:33:14 · 158 阅读 · 0 评论