Comments (1)
By default, all parameters of a model will be updated during the training process. If you want to train only classifier, you could 'freeze' feature extracting layers by setting requires_grad=False
:
for param in model._features.parameters():
param.requires_grad = False
# Print layers whose parameters will be updated during training.
# Should print only names of classifying layers.
print([name for (name, param) in model.named_parameters() if param.requires_grad])
You will also need to pass only parameters from 'unfrozen' layers to an optimizer or you will get an exception
optimizer = optim.SGD((param for param in model.parameters() if param.requires_grad), lr=..., momentum=...)
from pytorch-cnn-finetune.
Related Issues (20)
- Training loss might not be summed HOT 2
- pretrained model will be downloaded when pretrained set as True HOT 1
- Build my own model and add it to the models in your package HOT 1
- illegal instruction (core dumped) HOT 2
- Access to fc layer HOT 1
- torchvision support `mobilenet` and `shufflenet` HOT 3
- save mode HOT 1
- Auto Flattening of features HOT 1
- mean and std used in the transform of the Cifar10 example HOT 1
- Strange mean and std for inception_v4. HOT 2
- ask a question
- how can i load the trained-model HOT 2
- Kernel size issue with "inceptionresnetv2"
- 'DPN' object has no attribute 'input_space' Cifar10 example HOT 5
- Output size issue in alexnet and inception HOT 5
- Some warnings due to updating PyTorch to version 0.4.0 HOT 1
- Finetune on multi-GPUs HOT 7
- Error(s) in loading state_dict for Xception HOT 5
- How to replace last FC layer by 1x1 convolution? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-cnn-finetune.