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

Fix bug in render_network #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

feynmanliang
Copy link

@feynmanliang feynmanliang commented Sep 12, 2018

L121 makes it so that index is never 0


This change is Reviewable

@msultan
Copy link
Owner

msultan commented Sep 12, 2018

ahh good catch with the index, I think it ended up not too much of an issue because I switched towards called in input features layer (cell number [65] ) "l0" instead of "f0".

arg=','.join(["f%d_%d"%(layer_indx-1,j) for j in range(lp.in_features)])
else:
arg=','.join(["l%d_%d"%(layer_indx-1,j) for j in range(lp.in_features)])

weights = ','.join(map(str,lp.weight[i].data.tolist()))
bias =','.join(map(str,lp.bias[i].data.tolist()))
try:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing you have 1 feature in the input so this was causing an issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encountered this on the 2-alanine example, so there's 4 (2 sin and 2 cos).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, weird, i will investigate this further then.

Copy link
Owner

@msultan msultan Sep 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code gives the correct behavior without in both instances if lp is a list but it is possible that pytorch has changed how it returns the bias when tolist() is called.

In [12]: lp=[1]

In [13]: ','.join(map(str,lp))
Out[13]: '1'

In [14]: lp=[1,2,3,4]

In [15]: ','.join(map(str,lp))
Out[15]: '1,2,3,4'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically, we only need a str that can be streamed to text file for plumed

Copy link
Author

@feynmanliang feynmanliang Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the problem I was running in to was that tolist was returning a scalar, i.e .','.join(map(str, 1)), which results in a TypeError since 1 is not iterable

@msultan
Copy link
Owner

msultan commented Sep 12, 2018

if you are done with the PR, i can merge the changes. Thanks for bringing these in, I really appreciate it.

@feynmanliang
Copy link
Author

Sure go ahead and merge, I'll send more as I work.

FYI I'm using the vde package under msmbuilder

try:
bias =','.join(map(str,lp.bias[i].data.tolist()))
except TypeError:
bias = str(lb.bias[i].data.tolist())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be lp.bias[i] not lb.bias[i]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, fixed!

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

Successfully merging this pull request may close these issues.

2 participants