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

Port code to python 3 #53

Open
TotallyNotChase opened this issue Jan 31, 2020 · 9 comments
Open

Port code to python 3 #53

TotallyNotChase opened this issue Jan 31, 2020 · 9 comments

Comments

@TotallyNotChase
Copy link
Collaborator

TotallyNotChase commented Jan 31, 2020

Python 2 has reached EOL and it's time for this repo to upgrade. I've been working on a basic port for awhile and I'd like to detail my approach-

General

  • encoding='utf-8' will be included as an extra parameter in all open(....) commands
  • print 'string' will be changed to print('string')
  • raw_input (s) will be changed to input()
  • dict.iterItems() will be changed to dict.items()

Tensorflow

We will be using tensorflow 2.1.0, please note there has been drastic changes in this version compared to the one we are using. I'm only focusing on replacing the old commands with their alternatives. The new tensorflow probably offers many improved features and it might even have different behaviours for the existing commands, which I'll not be focusing on.

  • tf.Session() will be replaced with tf.compat.v1.Session()
  • Going to use tf.compat.v1.disable_eager_execution(), without this we cannot use placeholder()
  • tf.random_uniform() will be replaced with tf.random.uniform()
  • tf.truncated_normal() will be replaced with tf.random.truncated_normal()
  • tf.placeholder() will be replaced with tf.compat.v1.placeholder
  • tf.train.GradientDescentOptimizer() will be replaced with tf.compat.v1.train.GradientDescentOptimizer()
  • tf.global_variables_initializer() will be replaced with tf.compat.v1.global_variables_initializer()

*more changes soon

As of now, createDataset.py and Word2Vec.py are completely overhauled with python 3, I am currently working on porting Seq2Seq.py and will be posting my progress and/or hurdles here. Please be on a lookout for that!

@TotallyNotChase
Copy link
Collaborator Author

@adeshpande3 let me know what you think of these changes, and also if you'd like me to know anything while porting.

@adeshpande3
Copy link
Owner

Yeah this sounds fantastic to me, appreciate it! Lmk if I can be helpful

@TotallyNotChase
Copy link
Collaborator Author

@adeshpande3 Everything except tf.contrib.legacy_seq2seq has an alternative in tensorflow 2.1.0. This blocks me from upgrading Seq2Seq.py to python 3. I'm not really experienced enough to come up with an alternative to that, could you look into that a bit?
All the changes are live in the branch python3-upgrade, you can experiment in there. Also keep in mind the new codebase must use python3 64 bit. I personally used 3.7 64 bit

@adeshpande3
Copy link
Owner

Ahhh gotcha interesting, don't have as much bandwidth rn but will take a look over the weekend. I have no doubt there is an alternative but it'll probably require a bit of a refactor.

@TotallyNotChase
Copy link
Collaborator Author

@adeshpande3 any updates on legacy_seq2seq?

@adeshpande3
Copy link
Owner

Hey, unfortunately I was only able to take a cursory look. Unfortunately this stemmed from me making the choice back then to use a tf.contrib.legacy function which as the name implied was likely not going to be supported for long.

Will try to take another look this weekend, but think it might be slightly costly to rearchitect and ramp back up on to find a solution. I'm open to finding other folks to help maintain this though (since I know I haven't had as much free time). Is there a way to make this a formal Issue and see if folks can contribute?

@TotallyNotChase
Copy link
Collaborator Author

TotallyNotChase commented Feb 14, 2020

@adeshpande3 I think that's our only choice. I'd appreciate it if you could make an issue describing some primary things-

  • Exactly what the function currently does
  • What we expect a refactor to also achieve
  • A preferred solution path if you have one

Also some guidelines when someone does take it on -

  • Test and Work on the python3-upgrade branch
  • Code should be for python3 (preferably 64 bit for cross platform compatibility?)

The reason I'd like you to do this is because you've a better understanding of this function than I do haha

@adeshpande3
Copy link
Owner

Ya totally fair. Will do so by Sunday night at the latest. Thanks for pushing on this

@elijaholmos
Copy link

any updates on this?

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

3 participants