-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to import model parameters without participating in training #1265
Comments
怎么导入模型参数不参与训练 如: |
In TorchSharp it would look the same: var model = ...;
foreach (var param in model.parameters())
param.requires_grad = False; |
model = models.vgg16(pretrained = True) How to import the trained parameters of python tourch model |
I suppose it could be another issue. I've tried that, but it seems that currently there are no beautiful solutions available. If you don't mind, maybe you could download the pre-trained model with pytorch, and then try TorchSharp.PyBridge or exportsd.py to load it into csharp. Actually |
I have uploaded the converted model to hugging face. Could the following code work for you? using TorchSharp;
var huggingFace = "https://huggingface.co/";
// var huggingFace = "https://hf-mirror.com/";
var file = new FileInfo("./vgg16.dat");
if (!file.Exists)
torch.hub.download_url_to_file(
$"{huggingFace}yueyinqiu/vision-TorchSharp/resolve/main/VGG16_Weights.IMAGENET1K_V1",
file.FullName);
var model = torchvision.models.vgg16(weights_file: file.FullName); |
@zengnanhua - Is this still an issue? If resolved, please close. If not, please see if you can reply to @yueyinqiu's question. |
How to import model parameters without participating in training
The text was updated successfully, but these errors were encountered: