我正试图从未经预训练的模型中提取特征,以使我想使用自己的数据集。
我尝试遵循一个预先训练的示例,但无法使其正常工作。
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)