
动态深度学习框架Pytorch
gz153016
格局,品味
展开
-
torch.nn.Linear() 理解
# -- coding: utf-8 --import torchx = torch.randn(128, 20) # 输入的维度是(128,20)m = torch.nn.Linear(20, 30) # 20,30是指维度output = m(x)# (128, 20) (20, 30) -> (128, 30)print('m.weight.shape:\n ', m.weight.shape) # torch.Size([30, 20])print('m.bias.sh原创 2021-07-26 15:54:00 · 270 阅读 · 0 评论 -
一个简单的pytorch执行例子
#导入所需要的包import torchimport numpy as npimport torch.nn as nnimport matplotlib.pyplot as pltfrom torch.autograd import Variable #定义超参数input_size = 1output_size = 1num_epochs = 100learning_rate = 0.001 #数据集x_train = np.array([[3.3], [4.4], [5.5]原创 2021-07-02 22:08:30 · 347 阅读 · 0 评论 -
Pytorch什么时候开始调用forward
import torchfrom torch import nnclass MLP(nn.Module): # 声明带有模型参数的层,这里声明了两个全连接层 def __init__(self, **kwargs): # 调用MLP父类Module的构造函数来进行必要的初始化。这样在构造实例时还可以指定其他函数 # 参数,如“模型参数的访问、初始化和共享”一节将介绍的模型参数params super(MLP, self).__init__原创 2021-01-16 23:03:51 · 785 阅读 · 0 评论 -
元学习-maml-few-shot learning-代码实战
第一个文件:my_miniimagenet_train.pyimport osos.environ['CUDA_VISIBLE_DEVICES']='0'import torchfrom my_MiniImagenet import MiniImagenetimport numpy as npfrom my_meta import Metaimport argparsefrom torch.utils.data import DataLoaderdef main(): .原创 2020-11-21 15:45:24 · 2125 阅读 · 1 评论 -
Pytorch-PackageNotFoundError: Packages missing in current channels:解决办法
1.anaconda search -t conda pytorch2.anaconda show prigoyal/pytorch(对应的版本好)3.执行最后一行的命令,就可以下载了!至此,我想要安装的包就下载好了原创 2020-10-08 12:40:48 · 3137 阅读 · 0 评论