Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something Wrong #1

Open
charlesfufu opened this issue Oct 16, 2018 · 43 comments
Open

Something Wrong #1

charlesfufu opened this issue Oct 16, 2018 · 43 comments

Comments

@charlesfufu
Copy link

image

@ShomyLiu
Copy link
Owner

Hi, file is only in Python 2.7X, and your python version is 3.6. You can try replace file into open

@charlesfufu
Copy link
Author

Hi, file is only in Python 2.7X, and your python version is 3.6. You can try replace file into open

image
How about this one?

@ShomyLiu
Copy link
Owner

The training phase should be in this way in the terminal:

python main_sem.py  train

If you run code in IDE (e.g., Pycharm) , You can modify the __main__ function with:

if __name__ == "__main__":
     train()

@charlesfufu
Copy link
Author

The training phase should be in this way in the terminal:

python main_sem.py  train

If you run code in IDE (e.g., Pycharm) , You can modify the __main__ function with:

if __name__ == "__main__":
     train()

According to what you say, get the same result.

@ShomyLiu
Copy link
Owner

The normal output of main_sem should be:
image

Maybe the environment difference?

@charlesfufu
Copy link
Author

def train(**kwargs):
image
Where is the value of the parameter?

@charlesfufu
Copy link
Author

The normal output of main_sem should be:
image

Maybe the environment difference?

Maybe you should upgrade your program with python3

@charlesfufu
Copy link
Author

The normal output of main_sem should be:
image
Maybe the environment difference?

Maybe you should upgrade your program with python3

image
I don't know if you write program like these *** if name == "main": train()***,how to pass in the value at def train(**kwargs) function ?

@ShomyLiu
Copy link
Owner

OK, I will update my code with Python3.X.
You can change config.py Line 66:

.iteritems()   ->   .items()
```
Maybe there will be other codes different from python2.x and 3.x

@charlesfufu
Copy link
Author

OK, I will update my code with Python3.X.
You can change config.py Line 66:

.iteritems()   ->   .items()

Maybe there will be other codes different from python2.x and 3.x

Yes, I had found at least four difference between python2 and python3. Looking forward to your code with python3. Thanks! !

@ShomyLiu
Copy link
Owner

Yes, I'm trying to update with python3. And I think it would be better with Pytorch 0.4 or later in the revision.

@charlesfufu
Copy link
Author

The normal output of main_sem should be:
image
Maybe the environment difference?

Maybe you should upgrade your program with python3

image
I don't know if you write program like these *** if name == "main": train()***,how to pass in the value at def train(**kwargs) function ?

image
I can not run the part program of picture. Do you know what's reason causes these? my pytorch version is 0.4

@ShomyLiu
Copy link
Owner

Yeah. My code is in Pytorch0.3. I'm updating code into Python3.x and Pytorch 0.4

@ShomyLiu
Copy link
Owner

@charlesfufu The code has updated. the master branch is under Python 3.5x and Pytorch 0.4+.

@charlesfufu
Copy link
Author

@charlesfufu The code has updated. the master branch is under Python 3.5x and Pytorch 0.4+.

Wonderful !!

@charlesfufu
Copy link
Author

@charlesfufu The code has updated. the master branch is under Python 3.5x and Pytorch 0.4+.

Wonderful !!

image
Do you know why?

@Wangpeiyi9979
Copy link
Contributor

Wangpeiyi9979 commented Oct 16, 2018

try changing the "use_gpu" in config.py to False.

@charlesfufu
Copy link
Author

try changing the "use_gpu" in config.py to False.

still wrong

@Wangpeiyi9979
Copy link
Contributor

Is the same wrong message?

@charlesfufu
Copy link
Author

Is the same wrong message?

yeah!!Maybe is not GPU problem.

@Wangpeiyi9979
Copy link
Contributor

image
try changing the codes here to this

@charlesfufu
Copy link
Author

image
try changing the codes here to this

image
No,that's wrong.

@Wangpeiyi9979
Copy link
Contributor

image
this?

@Wangpeiyi9979
Copy link
Contributor

Wangpeiyi9979 commented Oct 16, 2018

image
also change the code here, and add long(). it may work

@charlesfufu
Copy link
Author

image

No, not right
Can I ask you about it, have you run it since the program was modified?

@Wangpeiyi9979
Copy link
Contributor

image

@charlesfufu
Copy link
Author

@Wangpeiyi9979 what about win10 ?

@Wangpeiyi9979
Copy link
Contributor

Wangpeiyi9979 commented Oct 16, 2018

@Wangpeiyi9979 what about win10 ?
it should work. changing the code here, add long()..
image

and here
image

@charlesfufu
Copy link
Author

@ShomyLiu

@ShomyLiu
Copy link
Owner

@charlesfufu I have reviewed code carefully and cannot reproduce your problems either in GPU or CPU.
Please check your environments.
My environments are listed here:

- OS: Ubuntu 16.04 
- Python: 3.5
- Pytorch: 0.4.1
- GPU: NVIDIA GTX 1080Ti with 387.34 drivers.

@charlesfufu
Copy link
Author

Have you tested your program on windows?I think maybe is the operating system problem

@charlesfufu
Copy link
Author

image
I had found the bug

@charlesfufu I have reviewed code carefully and cannot reproduce your problems either in GPU or CPU.
Please check your environments.
My environments are listed here:

- OS: Ubuntu 16.04 
- Python: 3.5
- Pytorch: 0.4.1
- GPU: NVIDIA GTX 1080Ti with 387.34 drivers.

image
I had found the bug ! !

@ShomyLiu
Copy link
Owner

OK, It seems strange. It would be nice If the issue has been solved. If necessary, you can create a pull request.
Thanks.

@ghost
Copy link

ghost commented Dec 10, 2018

image
I had found the bug

@charlesfufu I have reviewed code carefully and cannot reproduce your problems either in GPU or CPU.
Please check your environments.
My environments are listed here:

- OS: Ubuntu 16.04 
- Python: 3.5
- Pytorch: 0.4.1
- GPU: NVIDIA GTX 1080Ti with 387.34 drivers.

image
I had found the bug ! !
image

你好,我遇到和你一样的报错信息【上图】,但没找到应该在哪里修改这个bug。看起来是pytorch在对数据类型进行转换的时候出现的问题,请问你是如何解决的呢?最后整个模型可以跑起来了吗?

@XAKK
Copy link
Contributor

XAKK commented Mar 17, 2019

image
I had found the bug

@charlesfufu I have reviewed code carefully and cannot reproduce your problems either in GPU or CPU.
Please check your environments.
My environments are listed here:

- OS: Ubuntu 16.04 
- Python: 3.5
- Pytorch: 0.4.1
- GPU: NVIDIA GTX 1080Ti with 387.34 drivers.

image
I had found the bug ! !

Can you show the details about fixing this bug?

@ShomyLiu
Copy link
Owner

@XAKK
Hi, could you please show what's the problem here?
I have checked the codes and run successfully right now under the following environment:

  • Ubuntu 18.04
  • Python 3.X
  • Pytorch 0.4+ (1.0 is ok)

@XAKK
Copy link
Contributor

XAKK commented Mar 17, 2019

@ShomyLiu
Hi, I have the same problem as @charlesfufu
it seems that this problem only appear on the Windows.

Traceback (most recent call last):
File "main_sem.py", line 123, in
fire.Fire()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\fire\core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\fire\core.py", line 366, in _Fire
component, remaining_args)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\fire\core.py", line 542, in _CallCallable
result = fn(*varargs, **kwargs)
File "main_sem.py", line 64, in train
out = model(data[:-1])
File "C:\Users\79052\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "D:\SFOH\pytorch-pcnn-master\models\PCNN.py", line 72, in forward
lexical_level_emb = self.word_embs(lexical_feature) # (batch_size, 6, word_dim
File "C:\Users\79052\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "C:\Users\79052\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\sparse.py", line 118, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "C:\Users\79052\AppData\Roaming\Python\Python36\site-packages\torch\nn\functional.py", line 1454, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda.IntTensor instead (while checking arguments for embedding)

@ShomyLiu
Copy link
Owner

@XAKK
I will reproduce the problem in Windows platform as soon as possible and find out the solution.

@ShomyLiu ShomyLiu reopened this Mar 17, 2019
@XAKK
Copy link
Contributor

XAKK commented Mar 17, 2019

I think I found a problem solving strategy for Windows platform.
I modified the codes for three places, and run successfully on

  • Windows 10

  • Python 3.6

  • Pytorch 1.0

Here are the changes:
main_sem.py
line 65:
loss = criterion(out, data[-1])

out1 = out.type(torch.cuda.FloatTensor) data1 = data[-1].type(torch.cuda.LongTensor) loss = criterion(out1, data1)

line 92 - 95:
if opt.use_gpu: data = list(map(lambda x: torch.LongTensor(x).cuda(), data)) else: data = list(map(lambda x: torch.LongTensor(x), data))

if opt.use_gpu: # data = list(torch.cuda.LongTensor(long(i)) for i in data) data = list(map(lambda x: torch.LongTensor(x.long()).cuda(), data)) else: data = list(map(lambda x: torch.LongTensor(x.long()), data))

PCNN.py line 68:
lexical_feature, word_feautre, left_pf, right_pf = x

lexical_feature, word_feautre, left_pf, right_pf = x lexical_feature = lexical_feature.type(torch.cuda.LongTensor) word_feautre = word_feautre.type(torch.cuda.LongTensor) left_pf =left_pf.type(torch.cuda.LongTensor) right_pf = right_pf.type(torch.cuda.LongTensor)

This is part of my result with defualt setting

<<< (9+1)-WAY EVALUATION TAKING DIRECTIONALITY INTO ACCOUNT -- OFFICIAL >>>:
Micro-averaged result (excluding Other):
P = 1907/2409 = 79.16% R = 1907/2263 = 84.27% F1 = 81.64%

MACRO-averaged result (excluding Other):
P = 78.58% R = 83.26% F1 = 80.77%
Thank you! @ShomyLiu

@ShomyLiu
Copy link
Owner

@XAKK Thanks for the note.
I will refine the codes for windows recently.
It seems that the code above can be simplified with:

 out.type(torch.cuda.FloatTensor) -> out.float()
...

lexical_feature.type(torch.cuda.LongTensor) -> lexical_feature.long()

ShomyLiu pushed a commit that referenced this issue Mar 23, 2019
@Xin-Deng
Copy link

image
我并没有修改任何东西 目录下的确有该文件 为什么会找不到呢?

@ShomyLiu
Copy link
Owner

@learning-makes-me-happy-a 请确认下执行命令所在的目录。 需要在主目录,而不是说dataset下

@Xin-Deng
Copy link

@learning-makes-me-happy-a 请确认下执行命令所在的目录。 需要在主目录,而不是说dataset下

thanks I have solved this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants