如何从未经预先训练的模型中从头开始提取要素

时间:2019-07-11 15:26:32

标签: feature-extraction torchvision

我正试图从未经预训练的模型中提取特征,以使我想使用自己的数据集。

我尝试遵循一个预先训练的示例,但无法使其正常工作。

scratch_model = initialize_model(model_name, num_classes, feature_extract=False, use_pretrained=False)
scratch_model = scratch_model.to(device)
scratch_optimizer = optim.SGD(scratch_model.parameters(), lr=0.001, momentum=0.9)
scratch_criterion = nn.CrossEntropyLoss()
scratch_hist = train_model(scratch_model, dataloaders_dict, scratch_criterion, scratch_optimizer, num_epochs=num_epochs, is_inception=(model_name=="resnet"))

为此运行初始化模型

scratch_model, input_size = initialize_model(model_name, num_classes, feature_extract, use_pretrained=False)

0 个答案:

没有答案