-
Notifications
You must be signed in to change notification settings - Fork 2.1k
made tutorials compatible with python 3 #132
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
Conversation
Fix #114. |
Two tests are failing because of a change in Theano, in some place we did not expect code to use directly: the For conlleval, you can download a copy at http://www-etud.iro.umontreal.ca/~lamblinp/code/conlleval.pl so you can run (and port) Could you do that this week? |
I'll do this Thursday to be able to talk to you (Pascal and Fred) in person about issues that come up. Are you going to be at the lab ? |
I'm going to be there, but Fred is away until next week. |
Made changes from Fred's pull request. Also fixed rnnslu.py. Right now, this requires manually downloading conlleval.py into code/rnnslu/conlleval.py before running the script. |
c.append(pretraining_fns[i](index=batch_index, | ||
corruption=corruption_levels[i], | ||
lr=pretrain_lr)) | ||
print 'Pre-training layer %i, epoch %d, cost ' % (i, epoch), | ||
print numpy.mean(c) | ||
print('Pre-training layer %i, epoch %d, cost ' % (i, epoch)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not equivalent to the previous call: the previous call was printing something without a newline at the end, so that the next print
statement would append to the same line.
The equivalent for the new print()
function would be:
print('Pre-training layer %i, epoch %d, cost ' % (i, epoch), end='')
Other than that, it looks good to me, but I'll let @nouiz do a final review. |
I'll do a final review when @lamblin comment are addressed. thanks On Thu, Jan 28, 2016 at 5:47 PM, Pascal Lamblin notifications@github.com
|
I don't get a notification when a new commit is added to a PR. Add a comment to the PR when you want one of us to review it again. |
@@ -7,6 +7,7 @@ | |||
""" | |||
|
|||
|
|||
from six.moves import xrange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be a better example to follow if we don't use this import and change everywhere xrange to range. Can you do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change all the instances with range instead of xrange. That's what I did at first, but then I figured the proper way to use xrange in a compatible way. I'll just use range for all cases. They're "safe" in the sense that none of those calls require fast execution.
Can you add this in the .travis file to have travis run with python 3?
What is the problem with rnnrbm? The midi related files? For this one can you download this zip file: http://www.iro.umontreal.ca/~lisa/deep/midi.zip and make a new zip with the files updated to python 3? I will then update it on the server. (and remove the command related to it) thanks |
The issue with the rnnrbm is that the midi library is not loading properly in python 3 because it uses one way to refer to its internal files instead of the python 3 way. I spoke with Pascal about this, and he knows better what I'm talking about. If we can update the midi.zip file, then it's possible to fix this, and this is what I'll do. |
thanks On Mon, Feb 1, 2016 at 1:35 PM, Guillaume Alain notifications@github.com
|
except: | ||
# python 3 compatibility | ||
# http://stackoverflow.com/questions/3073259/python-nose-import-error | ||
from hmc.hmc import HMC_sampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I have more insight about this.
In this case, the issue is a clash of names between the hmc/
directory and the hmc.py
file inside. On Python 3, nosetests
thinks hmc
is the directory, but the regular Python interpreter thinks it is hmc.py
(if you try to import test_hmc
for instance, or run python test_hmc.py
).
This looks like an issue with nosetests to me. Possible solutions would include:
- Yours (except that I would catch only
ImportError
rather than anything) - Having different names, by either renaming
hmc/
orhmc.py
. That would break direct links, though.
I would prefer the first one.
However, for midi
, I'm not sure that the issue is the same exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer option 1.
For |
conlleval has already been fixed in master. |
Also, this PR need a rebase, it have conflict with master. |
In terms of language compatibility and imported modules, I have made the "midi" module work with python 2 and 3. Now, the problem is that it has difficulties loading midi files. It works fine in python 2, but in python 3 I get this error. Traceback (most recent call last): At first glance, this seems like it's a problem when decoding the raw files. This might be due to byte array encodings, with strings being used for one purpose in python 2 that just doesn't translated well into python 3. I'm signaling this because I'm now no longer strictly in the "straightforward port from python 2 to 3", but probably more into the development of the "midi" module where I'm required to figure out what the code does and what it's trying to do to decode midi files. The question becomes whether this falls outside of the scope of the original ticket or not. I won't commit this "midi" code in the DeepLearningTutorials in any case, but I can put it elsewhere if you want to have a look at it. |
Can you give us access to that midi version? On Wed, Feb 3, 2016 at 4:29 PM, Guillaume Alain notifications@github.com
|
…module to make it compatible with python 3
…but not to completion
travis tests are failing due to that: File "/home/travis/build/lisa-lab/DeepLearningTutorials/code/rnnslu.py", line 144 this is the new change in master that requested a rebase. |
Should be fixed. We'll see what travis reports. |
thanks. merging. |
made tutorials compatible with python 3
made tutorials compatible with python 3
made tutorials compatible with python 3 Former-commit-id: 2efc6cb
All the examples from the main page (http://deeplearning.net/tutorial/) have been updated, except for two.
They have all been tested, to then extent that they run fine with python 2 and python 3, for 10-20 minutes, but I didn't have a GPU available to run them to completion (potential source for errors in final lines of scripts).
rnnrbm.py has an issue with the "midi" module that is downloaded from an external source. I am led to believe that it is not compatible with python 3 due to the way that it loads local sources. Not sure if this is fixable without modifying the "midi" module.
With rnnslu.py, the existing code currently fails to run on python 2 without any changes to the code. Not sure if Gregoire Mesnil is responsible for maintaining this code. For one thing, the script is referring to the url http://www-etud.iro.umontreal.ca/~mesnilgr/atis/conlleval.pl which is currently broken.