搭建一个简简单单的2D卷积神经网络

import torch
import torch.nn as nn
import torch.nn.functional as F
#2D卷积神经网络
input = torch.randn(1, 1, 28, 28)

# With square kernels and equal stride
conv1 = nn.Conv2d(1, 10, kernel_size=5)
conv2 = nn.Conv2d(10, 20, kernel_size=5)
conv2_drop = nn.Dropout2d()
fc1 = nn.Linear(320, 50)
fc2 = nn.Linear(50, 10)


X = F.relu(F.max_pool2d(conv1(input),2))
X = F.relu(F.max_pool2d(conv2_drop(conv2(X)),2))
X = X.view(-1, 320)
X = F.relu(fc1(X))
X = F.dropout(X, training=True)
X = fc2(X)
X = F.log_softmax(X, dim=0)


print("output shape is {}".format(X.shape))

=================

1、学会了如何快速调整、改变每一层张量的大小;

2、学会了 搭建网络模型准备训练数据 相互解耦的流程;

3、学会了 如何阅读别人网络结构;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值