On well formatted inputs (without nan) linear transformation is returning NaN:
vec_tensor = torch.from_numpy(vec)
# check if input is nan
if np.isnan(np.sum(vec_tensor.cpu().numpy())):
print("some values from input are nan")
x = vec_tensor[:,0:ZONE_SIZE*2]
x = x.view(-1, ZONE_SIZE * 2)
x_mean = torch.mean(x, dim=1).view(-1,1)
x_std = torch.std(x, dim=1).view(-1,1)
x = (x -x_mean) / x_std
o = net.linear1(x)
print (o)
And the result is:
tensor([[nan., nan., nan., ..., nan., nan., nan.],
[nan., nan., nan., ..., nan., nan., nan.],
[nan., nan., nan., ..., nan., nan., nan.],
...,
[nan., nan., nan., ..., nan., nan., nan.],
[nan., nan., nan., ..., nan., nan., nan.],
[nan., nan., nan., ..., nan., nan., nan.]])
Repo with the faulty network params and vector is here: https://github.com/ssainz/pytorch_bug
Versions are:
backports-abc (0.5)
backports.functools-lru-cache (1.5)
backports.shutil-get-terminal-size (1.0.0)
bleach (2.1.3)
certifi (2018.4.16)
chardet (3.0.4)
configparser (3.5.0)
cycler (0.10.0)
decorator (4.3.0)
entrypoints (0.2.3)
enum34 (1.1.6)
functools32 (3.2.3.post2)
future (0.16.0)
futures (3.2.0)
gym (0.10.5)
html5lib (1.0.1)
idna (2.6)
ipykernel (4.8.2)
ipython (5.7.0)
ipython-genutils (0.2.0)
ipywidgets (7.2.1)
Jinja2 (2.10)
jsonschema (2.6.0)
jupyter (1.0.0)
jupyter-client (5.2.3)
jupyter-console (5.2.0)
jupyter-core (4.4.0)
kiwisolver (1.0.1)
MarkupSafe (1.0)
matplotlib (2.2.2)
mistune (0.8.3)
nbconvert (5.3.1)
nbformat (4.4.0)
networkx (1.11)
notebook (5.5.0)
numpy (1.14.4)
pandocfilters (1.4.2)
pathlib2 (2.3.2)
pexpect (4.6.0)
pickleshare (0.7.4)
Pillow (5.1.0)
pip (9.0.1)
prompt-toolkit (1.0.15)
ptyprocess (0.5.2)
pyglet (1.3.2)
Pygments (2.2.0)
pyparsing (2.2.0)
python-dateutil (2.7.3)
pytz (2018.4)
pyzmq (17.0.0)
qtconsole (4.3.1)
requests (2.18.4)
scandir (1.7)
scipy (1.1.0)
Send2Trash (1.5.0)
setuptools (28.8.0)
simplegeneric (0.8.1)
singledispatch (3.4.0.3)
six (1.11.0)
subprocess32 (3.5.2)
terminado (0.8.1)
testpath (0.3.1)
torch (0.4.0)
torchvision (0.2.1)
tornado (5.0.2)
traitlets (4.3.2)
urllib3 (1.22)
wcwidth (0.1.7)
webencodings (0.5.1)
wheel (0.29.0)
widgetsnbextension (3.2.1)
Been able to reproduce this in 3 different machines with cpu and gpu~