欢迎访问 生活随笔!

凯发ag旗舰厅登录网址下载

当前位置: 凯发ag旗舰厅登录网址下载 > 人工智能 > 卷积神经网络 >内容正文

卷积神经网络

卷积神经网络的网络层与参数的解析 -凯发ag旗舰厅登录网址下载

发布时间:2025/1/21 卷积神经网络 34 豆豆
凯发ag旗舰厅登录网址下载 收集整理的这篇文章主要介绍了 卷积神经网络的网络层与参数的解析 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

参考博主:https://blog.csdn.net/weixin_41457494/article/details/86238443

import torch from torch.autograd import variable import torch.nn as nn import torch.nn.functional as f # 神经网络参数解析 ''' 神经网络参数解析 ''' class net(nn.module):def __init__(self):super(net, self).__init__()# 1 input image channel, 6 output channels, 5x5 square convolution# kernelself.conv1 = nn.conv2d(1, 6, 2)# an affine operation: y = wx bself.fc1 = nn.linear(6 * 3 * 3, 4)def forward(self, x):# max pooling over a (2, 2) windowprint("x.size:{}".format(x.size()))x = f.max_pool2d(f.relu(self.conv1(x)), (2, 2),stride=1)print('================')print("x.size:{}".format(x.size()))x = x.view(-1, self.num_flat_features(x))x = f.relu(self.fc1(x))return xdef num_flat_features(self, x):size = x.size()[1:] # all dimensions except the batch dimensionnum_features = 1for s in size:num_features *= sreturn num_featuresif __name__ =='__main__':net = net() # print("net:{}".format(net)) # print(net)params = list(net.parameters())print("创建的神经网络共有{}组参数\n".format(len(params)))print("卷积核的初始化参数:{}\n".format(params[0]))print("卷积核的初始化bias:{}\n".format( params[1]))print("全连接层的初始化参数:{}\n".format( params[2]))print("全连接层的初始化bias:{}\n".format( params[3]))print("卷积核的初始化参数的size:{}\n".format(params[0].size()))print("卷积核的初始化bias的size:{}\n".format( params[1].size()))print("全连接层的初始化参数的size:{}\n".format( params[2].size()))print("全连接层的初始化bias的size:{}\n".format( params[3].size()))input = variable(torch.randn(1, 1, 5, 5))output = net(input)

总结

以上是凯发ag旗舰厅登录网址下载为你收集整理的卷积神经网络的网络层与参数的解析的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。

  • 上一篇:
  • 下一篇:
网站地图