pirl's People
Forkers
adepommereaupirl's Issues
Issue with the IntermediateLayerGetter class
Hi,
Thanks for sharing your brillant work!
I have one question regarding your IntermediateLayerGetter class. I am confused with your get_hook() and hook() functions. Are they not meant to be one?
def get_hook(self, name): def hook(module, input, output): device = output.get_device() self.activations.setdefault(name, {})[device] = output self.output_sizes[name] = output.size(1) return hook
I have been trying to solve it but without success..
Thanks!
how to use alexnet backbone
I got error when trying to use alexnet backbone. I added in PIRL.py to include alexnet below :
Model_Dict ={
'resnet': ['layer4'],
'densenet': ['features'],
'shufflenet': ['conv5'],
'alexnet': ['avgpool']
model summary as follow :
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 64, 19, 19] 23,296
ReLU-2 [-1, 64, 19, 19] 0
MaxPool2d-3 [-1, 64, 9, 9] 0
Conv2d-4 [-1, 192, 9, 9] 307,392
ReLU-5 [-1, 192, 9, 9] 0
MaxPool2d-6 [-1, 192, 4, 4] 0
Conv2d-7 [-1, 384, 4, 4] 663,936
ReLU-8 [-1, 384, 4, 4] 0
Conv2d-9 [-1, 256, 4, 4] 884,992
ReLU-10 [-1, 256, 4, 4] 0
Conv2d-11 [-1, 256, 4, 4] 590,080
ReLU-12 [-1, 256, 4, 4] 0
MaxPool2d-13 [-1, 256, 1, 1] 0
AdaptiveAvgPool2d-14 [-1, 256, 6, 6] 0
Dropout-15 [-1, 9216] 0
Linear-16 [-1, 4096] 37,752,832
ReLU-17 [-1, 4096] 0
Dropout-18 [-1, 4096] 0
Linear-19 [-1, 4096] 16,781,312
ReLU-20 [-1, 4096] 0
Linear-21 [-1, 1000] 4,097,000
AlexNet-22 [-1, 1000] 0
AdaptiveAvgPool2d-23 [-1, 256, 1, 1] 0
Linear-24 [-1, 64] 16,384
BatchNorm1d-25 [-1, 64] 128
LeakyReLU-26 [-1, 64] 0
GenericTask-27 [-1, 64] 0
================================================================
Total params: 61,117,352
Trainable params: 61,117,352
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.07
Forward/backward pass size (MB): 1.19
Params size (MB): 233.14
Estimated Total Size (MB): 234.41
----------------------------------------------------------------
But then there is an error like this :
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-9-00e192360482> in <module>
18
19 # compute output
---> 20 image_features, transformed_image_features = model(image.cuda(), transformed_image.cuda())
21 transformed_output, output, _ = memorybank(image_features, transformed_image_features, index)
22
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)
D:\Ramdhan\SSL\PIRL-master\Models\PIRL.py in forward(self, image, transformed_image)
37 transformed_image = torch.cat([*transformed_image], dim=0)
38 #Collapsing batch and patch dimensions
---> 39 _ = self.net(transformed_image)
40 image_activations = self.ILG.activations[self.layer_names[0]][transformed_image.get_device()]
41 transformed_image_features = self.Jigsaw(image_activations)
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)
~\Anaconda3\envs\nlp\lib\site-packages\torchvision\models\alexnet.py in forward(self, x)
43
44 def forward(self, x):
---> 45 x = self.features(x)
46 x = self.avgpool(x)
47 x = torch.flatten(x, 1)
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\container.py in forward(self, input)
98 def forward(self, input):
99 for module in self:
--> 100 input = module(input)
101 return input
102
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
548 result = self._slow_forward(*input, **kwargs)
549 else:
--> 550 result = self.forward(*input, **kwargs)
551 for hook in self._forward_hooks.values():
552 hook_result = hook(self, input, result)
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\modules\pooling.py in forward(self, input)
139 return F.max_pool2d(input, self.kernel_size, self.stride,
140 self.padding, self.dilation, self.ceil_mode,
--> 141 self.return_indices)
142
143
~\Anaconda3\envs\nlp\lib\site-packages\torch\_jit_internal.py in fn(*args, **kwargs)
207 return if_true(*args, **kwargs)
208 else:
--> 209 return if_false(*args, **kwargs)
210
211 if if_true.__doc__ is None and if_false.__doc__ is not None:
~\Anaconda3\envs\nlp\lib\site-packages\torch\nn\functional.py in _max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode, return_indices)
537 stride = torch.jit.annotate(List[int], [])
538 return torch.max_pool2d(
--> 539 input, kernel_size, stride, padding, dilation, ceil_mode)
540
541 max_pool2d = boolean_dispatch(
RuntimeError: Given input size: (256x1x1). Calculated output size: (256x0x0). Output size is too small
any idea to solve it ?
thank you
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.