一.matplotlib绘图程序运行无反应
import os
os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'
二.numpy中sqrt()h和square()
numpy中:
sqrt():求数字的算数平方根,
square():求数字的平方
三.查看神经网络的参数信息
class Network(nn.Module):
def __init__(self):
super(Network,self).__init__()
self.conv1 = nn.Conv2d(in_channels=1, out_channels=6,kernel_size=5) #6个滤波器,单通道,卷积核尺寸(5,5)
self.conv2 = nn.Conv2d(in_channels=6,out_channels=12,kernel_size=5)
self.fc1 = nn.Linear(in_features=12*4*4,out_features=120)
self.fc2 = nn.Linear(in_features=120,out_features=60)
self.out = nn.Linear(in_features=60,out_features=10)
def forward(self):
pass
----------------------------------------------
for name,param in network.named_parameters():
print(name,'\t\t',param.shape)
运行结果:
conv1.weight torch.Size([6, 1, 5, 5])
conv1.bias torch.Size([6])
conv2.weight torch.Size([12, 6, 5, 5])
conv2.bias torch.Size([12])
fc1.weight torch.Size([120, 192])
fc1.bias torch.Size([120])
fc2.weight torch.Size([60, 120])
fc2.bias torch.Size([60])
out.weight torch.Size([10, 60])
out.bias torch.Size([10])