0020-pytorch-自定义网络进行分类
作者:互联网
# -*- coding: utf-8 -*-
"""
Created on 2019/9/29 23:52
@author: Johnson
Email:593956670@qq.com
@software: PyCharm
"""
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import torchvision.transforms as tranforms
import torchvision
from torch.utils.data import DataLoader
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from torchvision.utils import make_grid
def imshow_batch(sample_batch):
images = sample_batch[0]
labels = sample_batch[1]
images = make_grid(images, nrow=4, pad_value=255)
# 1,2, 0
images_transformed = np.transpose(images.numpy(), (1, 2, 0))
plt.imshow(images_transformed)
plt.axis('off')
labels = labels.numpy()
plt.title(labels)
class Net(nn.Module):
'''
自定义的CNN网络,3个卷积层&#x
标签:0020,plt,nn,自定义,torch,batch,pytorch,images,import 来源: https://blog.csdn.net/zhonglongshen/article/details/112805857