Comments (10)
@zarakikun
like this
def forward(self, x):
for name, module in self.base._modules.items():
if name == 'avgpool':
break
x = module(x)
if self.cut_at_pooling:
return x
x = F.avg_pool2d(x, x.size()[2:])
x = x.view(x.size(0), -1)
pool5=x
if self.has_embedding:
x = self.feat(x)
x = self.feat_bn(x)
if self.norm:
x = F.normalize(x)
elif self.has_embedding:
x = F.relu(x)
if self.dropout > 0:
x = self.drop(x)
if self.num_classes > 0:
x = self.classifier(x)
return x ,pool5
from open-reid.
@ahkarami No, you don't have to. Just
outs = []
x = self.feat(x)
outs.append(x)
...
return outs
from open-reid.
@Linranran I have the same question, too. Have you figured out that? I am new with pytorch and will be happy that if you can give me some suggestions.
from open-reid.
@liangbh6 you can change a little at https://github.com/Cysu/open-reid/blob/master/reid/models/resnet.py ,just return one more variable .
def forward(self, x):
for name, module in self.base._modules.items():
if name == 'avgpool':
break
x = module(x)
you can mark the x and return it a in the end. you will get two features when put images into the model ,and chose the feature you wants.
i make it by this way.and pytorch have the function hook
,but i am not clear how to use it .
from open-reid.
@Linranran It works. Thank you for kind help! I think it's a very simple way to achieve that~
from open-reid.
Hi, I don't really understand your method, do u mean for example i wan to extract the features from pool 5, i do this?
def forward(self, x):
for name, module in self.base._modules.items():
if name == 'avgpool':
return x
from open-reid.
@zarakikun no ,do not do it this way.just mark the pool5 variable,and return it at the end .if you do it in your approach you will distroy the initial code and have to change a lot related code.you just marke the pool5 variable and return it in the end .and chose the returned variable that your want
from open-reid.
@Linranran would you mind showing me a snippet example of how you would retrieve for example pool5 features? thank you!
from open-reid.
Dear @Linranran,
Thank you for your answer. But I think if one want extract the correct & discriminative feature vector from a pre-trained model must return a variable after x = self.feat(x)
layer. Am I correct? What do you think?
from open-reid.
Dear @Cysu,
Thank you very much for your answer.
from open-reid.
Related Issues (20)
- Dependencies - setup.py
- is it generalised
- DukeMTMC dataset can't be downloaded HOT 2
- Problem with the file examine.softmax_loss.py HOT 5
- It can not converge on non-pretrained model HOT 1
- Train with only 1 camera in duke
- Viper is missing HOT 2
- TypeError: Can't instantiate abstract class Euclidean with abstract methods get_metric, score_pairs HOT 1
- How much video memory do I need? HOT 1
- DukeMTMC result reporting
- OIM loss HOT 1
- OIM loss initialize error
- IndexError: invalid index of a 0-dim tensor. HOT 6
- RuntimeError: zero-dimensional tensor (at position 0) cannot be concatenated
- RuntimeError: Duke
- TypeError: Can't instantiate abstract class Euclidean with abstract methods get_metric, score_pairs HOT 2
- something miss with sort and match? HOT 1
- AssertionError: Torch not compiled with CUDA enabled
- Oim Loss with 'NAN' problem
- eep q learning
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 open-reid.