I have this problem if you can help me please i don’t know why it changes from 64 to 2
i have checked the input and the output which resulted as the following
input_var = input
target_var = target
print("input var")
print(input.shape)
print ("target")
print(target.shape)
result : input var
torch.Size([64, 3, 224, 224])
target
torch.Size([64])
and after this line
output = model(input_var)
torch.Size([2, 1])
and it should output [64,1]
and this function which takes the input and return the output
def forward(self, input):
print("inputforward167")
print (input.shape)
#print(input)
#sample_len = (3 if self.modality == "RGB" else 2) * self.new_length
if self.modality == 'RGBDiff':
sample_len = 3 * self.new_length
input = self._get_diff(input)
if not self.slow_testing:#self.test_mode:
#print(input.shape)
#input= torch.as_tensor(torch.from_numpy(input)).permute(0,2,1,3,4).contiguous()
#input = torch.from_numpy(input).permute(0,2,1,3,4).contiguous()
#input.permute(0,2,1,3,4).contiguous()
#print(input.shape)
#input =torch.from_numpy(input)
input=input.view((-1,self.new_length,3)+ input.size()[-2:])
input=input.permute(0,2,1,3,4).contiguous()
print("input185")
print(input.shape)
#input= input.permute(0,2,1,3,4).contiguous()
#input = torch.from_numpy(input).permute(0,2,1,3,4).contiguous()
# input= torch.as_tensor(np.array(input).astype('float')).permute(0,2,1,3,4).contiguous()
#input=torch.tensor(input)
#input=torch.from_numpy(input)
#input=input.permute(0,2,1,3,4).contiguous()
#input=input.view((-1,self.new_length,3)+ input.size()[-2:])
else:
input=input.view((-1,3,self.new_length)+ input.size()[-2:])
print("inputbase")
print(input.shape)
base_out = self.base_model(input)
#base_out=F.dropout(base_out,p=0.5)
if self.gtsn:
base_out=base_out.view(base_out.shape[0]/self.num_segments,-1)
if self.dropout > 0:
base_out = self.new_fc(base_out)
if not self.gtsn:
if self.reshape:
base_out = base_out.view((-1, self.num_segments) + base_out.size()[1:])
#print "base out ",
#print(base_out.shape)
#base_out = np.squeeze(self.consensus(base_out),axis=-1)
base_out = self.consensus(base_out).squeeze(1)
if self.slow_testing:#apply_softmax:
base_out = self.softmax(base_out)
#base_out=torch.tensor(base_out)
print("base_out")
print(base_out)
print(base_out.shape)
return base_out#.squeeze(1)
else:
return base_out
and this is for base model
resnet50 = torchvision.models.resnet50(pretrained=True)
self.base_model= I3ResNet(resnet50, self.new_length,num_class,test_mode=test_mode,num_segments=self.num_segments,fast_implementation=fast_implementation)
self.new_fc = nn.Linear(2048, num_class)