之前我们使用nn.Sequential()都是直接写死的,就如下所示: # Example of using Sequential model = nn.Sequential( nn.Conv2d(,,), nn.ReLU(), nn.Conv2d(,,), nn.ReLU() ) # Example of using Sequential with OrderedDict model = nn.Sequential(OrderedDict([ (,,)), ('relu1', nn.ReLU(
Pytorch是torch的Python版本,对TensorFlow造成很大的冲击,TensorFlow无疑是最流行的,但是Pytorch号称在诸多性能上要优于TensorFlow,比如在RNN的训练上,所以Pytorch也吸引了很多人的关注.之前有一篇关于TensorFlow实现的CNN可以用来做对比. 下面我们就开始用Pytorch实现CNN. step 0 导入需要的包 import torch import torch.nn as nn from torch.autograd impor
import torch from torch.utils.data import DataLoader from torchvision import datasets from torchvision import transforms from torch import nn, optim from torch.nn import functional as F EPOCH = 1000 BATCH_SIZE = 128 LR = 0.001 DOWNLOAD_MNIST = False
文章:Clustering Convolutional Kernels to Compress Deep Neural Networks 链接:http://openaccess.thecvf.com/content_ECCV_2018/papers/Sanghyun_Son_Clustering_Kernels_for_ECCV_2018_paper.pdf 这篇文章主要是研究模型的压缩和加速.其他的文章大多数都只研究网络结构中的冗余参数或影响不大的结构,用剪枝的方法来压缩模型.作者从另一个方