Hi,i am new to pytorch from tensorflow.I get a problem when using pytorch.
Below is the init(self, n_visible,n_hidden,dropout_) function.An Auto Encoder
type: torch.cuda.FloatTensor
Traceback (most recent call last):
File "/home/zhanafeng/PycharmProjects/CollaborativeDeepLearning/main.py", line 147, in <module>
num_items,num_voca,itr,dipen_activation,pretrain_input,args)
File "/home/zhanafeng/PycharmProjects/CollaborativeDeepLearning/SDAE.py", line 101, in pretrain
Encoder,Decoder = model(train_loader)
File "/home/zhanafeng/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/zhanafeng/PycharmProjects/CollaborativeDeepLearning/SDAE.py", line 35, in forward
print("type:", x.type())
AttributeError: 'DataLoader' object has no attribute 'type'
I don’t know why a torch.cuda.FloatTensor changed to a ‘DataLoader’ object .And when i train the net,the trace is:
Traceback (most recent call last):
File "/home/zhanafeng/PycharmProjects/CollaborativeDeepLearning/main.py", line 147, in <module>
num_items,num_voca,itr,dipen_activation,pretrain_input,args)
File "/home/zhanafeng/PycharmProjects/CollaborativeDeepLearning/SDAE.py", line 101, in pretrain
Encoder,Decoder = model(train_loader)
File "/home/zhanafeng/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/zhanafeng/PycharmProjects/CollaborativeDeepLearning/SDAE.py", line 36, in forward
Encoder = F.sigmoid(self.fc1(x))
File "/home/zhanafeng/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/zhanafeng/anaconda3/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 55, in forward
return F.linear(input, self.weight, self.bias)
File "/home/zhanafeng/anaconda3/lib/python3.6/site-packages/torch/nn/functional.py", line 1022, in linear
if input.dim() == 2 and bias is not None:
AttributeError: 'DataLoader' object has no attribute 'dim'
for epoch in range(train_epoch):
model.train()
for step,(x,y) in enumerate(train_loader):
x = x.cuda()
y = y.cuda()
Encoder,Decoder = model(x)
loss = loss_func(Decoder,y)
optimizer.zero_grad()
loss.backward()
optimizer.step()
thanks.i find the bug.Encoder,Decoder = model(train_loader) is the below code of train code.i want to test the whole data.But i find a new bug now,my model did’t train.
thanks