pytorch之调用resnet、alexnet、vgg、squeezenet、densenet、inception预训练模型

pytorch调用resnet、alexnet、vgg、squeezenet、densenet、inception预训练模型

from __future__ import print_function 
from __future__ import division

import torch.nn as nn
from torchvision import datasets, models



# Top level data directory. Here we assume the format of the directory conforms 
#   to the ImageFolder structure




# Number of classes in the dataset
num_classes = 2

# Batch size for training (change depending on how much memory you have)
BATCH_SIZE = 128      #批处理尺寸(batch_size)


# Flag for feature extracting. When False, we finetune the whole model, 
#   when True we only update the reshaped layer params
feature_extract = True

是否改变卷及层的参数

def set_parameter_requires_grad(model, feature_extracting):
    if feature_extracting:
        for param in model.parameters():
            param.requires_grad = False

初始化模型

def initialize_model(mo
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值