![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
helloworld31006
多多分享,多多快乐!
展开
-
pytorch搭建一个小型的线性模型
代码:import torch as timport numpy as npt.set_default_tensor_type(t.DoubleTensor)x = np.array([[1.0, 2, 3, 4]])y = np.array([[4.0, 8, 12, 16]])X = t.from_numpy(x)X = X.view(-1, 1) # view 的作用相当于reshape, -1的意思时待计算机自己计算Y = t.from_numpy(y)Y = Y.view(原创 2021-05-06 19:50:17 · 187 阅读 · 0 评论 -
python 实现zigzag排列
最近在写zigzag排列的时候,感觉还是有点难写的,主要是判断条件有点多。所以就放到这里做一下笔记。def zigzag(data): # 输入应该是np.array类型的数组 (r, c) = data.shape if(r != c): print("行和列应该一样!") return 0 ZZ = zeros((1, r*c)) p = 0 for index in range(2 * r): if(ind原创 2021-04-19 20:39:57 · 2044 阅读 · 2 评论