上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 73 下一页
摘要: 1 nn.L1Loss torch.nn.L1Loss(reduction='mean') 就是 MAE(mean absolute error),计算公式为 $\ell(x, y)=L=\left\{l_{1}, \ldots, l_{N}\right\}^{\top}, \quad l_{n}= 阅读全文
posted @ 2022-03-09 09:21 别关注我了,私信我吧 阅读(581) 评论(0) 推荐(0)
摘要: 1、均匀分布初始化 torch.nn.init.uniform_(tensor, a=0, b=1) 从均匀分布U(a, b)中采样,初始化张量。 参数: tensor - 需要填充的张量 a - 均匀分布的下界 b - 均匀分布的上界 例子: w = torch.empty(3, 5) nn.in 阅读全文
posted @ 2022-03-08 20:09 别关注我了,私信我吧 阅读(1732) 评论(0) 推荐(0)
摘要: 1 导入包 import torch import numpy as np import torch.nn as nn from torch.utils.data import TensorDataset,DataLoader import torchvision from IPython impo 阅读全文
posted @ 2022-03-08 17:46 别关注我了,私信我吧 阅读(605) 评论(0) 推荐(0)
摘要: 1 导入实验需要的包 import torch import numpy as np from torch import nn from torchvision.datasets import MNIST import torchvision.transforms as transforms imp 阅读全文
posted @ 2022-03-08 17:00 别关注我了,私信我吧 阅读(604) 评论(0) 推荐(0)
摘要: 1 保存和加载整个模型 torch.save(model_object, 'model.pth') model = torch.load('model.pth') 2 仅保存和加载模型参数 torch.save(model_obj.state_dict(), 'params.pth') model_ 阅读全文
posted @ 2022-03-08 16:54 别关注我了,私信我吧 阅读(198) 评论(0) 推荐(0)
摘要: 1 导入包 import torch import torch.nn as nn from torch.utils.data import TensorDataset,DataLoader from torch.nn import init import torch.optim as optim f 阅读全文
posted @ 2022-03-07 20:30 别关注我了,私信我吧 阅读(537) 评论(0) 推荐(1)
摘要: 1 导入实验需要的包 import torch from torch import nn import numpy as np import matplotlib.pyplot as plt from torch.utils.data import DataLoader,TensorDataset 阅读全文
posted @ 2022-03-07 19:25 别关注我了,私信我吧 阅读(839) 评论(0) 推荐(0)
摘要: nn.Linear() PyTorch的 nn.Linear() 是用于设置网络中的全连接层的,需要注意在二维图像处理的任务中,全连接层的输入与输出一般都设置为二维张量,形状通常为[batch_size, size],不同于卷积层要求输入输出是四维张量。其用法与形参说明如下: torch.nn.Li 阅读全文
posted @ 2022-03-07 19:10 别关注我了,私信我吧 阅读(5036) 评论(0) 推荐(0)
摘要: 1、二维矩阵乘法 torch.mm() torch.mm(mat1, mat2, out=None) 其中 $\operatorname{mat} 1 \in \mathbb{R}^{n \times m}, \operatorname{mat} 2 \in \mathbb{R}^{m \times 阅读全文
posted @ 2022-03-07 15:40 别关注我了,私信我吧 阅读(311) 评论(0) 推荐(0)
摘要: 1 导入实验需要的包 import numpy as np import torch from torch import nn from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt f 阅读全文
posted @ 2022-03-06 11:56 别关注我了,私信我吧 阅读(720) 评论(0) 推荐(0)
上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 73 下一页
Live2D