摘要:
1、均匀分布初始化 torch.nn.init.uniform_(tensor, a=0, b=1) 从均匀分布U(a, b)中采样,初始化张量。 参数: tensor - 需要填充的张量 a - 均匀分布的下界 b - 均匀分布的上界 例子: w = torch.empty(3, 5) nn.in 阅读全文
摘要:
1 导入包 import torch import numpy as np import torch.nn as nn from torch.utils.data import TensorDataset,DataLoader import torchvision from IPython impo 阅读全文
摘要:
1 导入实验需要的包 import torch import numpy as np from torch import nn from torchvision.datasets import MNIST import torchvision.transforms as transforms imp 阅读全文
摘要:
1 保存和加载整个模型 torch.save(model_object, 'model.pth') model = torch.load('model.pth') 2 仅保存和加载模型参数 torch.save(model_obj.state_dict(), 'params.pth') model_ 阅读全文