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

Tutorial not working in Colab #32

Open
ZvikaZ opened this issue Aug 6, 2020 · 4 comments
Open

Tutorial not working in Colab #32

ZvikaZ opened this issue Aug 6, 2020 · 4 comments

Comments

@ZvikaZ
Copy link

ZvikaZ commented Aug 6, 2020

Hi.
I've tried running the TF-GAN Tutorial in Colab, and it's not working.

Few errors (there are more...):

SyntaxError                               Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/autograph/pyct/parser.py in _attempt_to_parse_lambda_source(source, original_source, future_features, try_fallback)
    157   try:
--> 158     return parse(source, preamble_len=len(future_features)), source
    159 

30 frames
SyntaxError: invalid syntax (<unknown>, line 1)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
ValueError: expected exactly one node node, found []

During handling of the above exception, another exception occurred:

UnsupportedLanguageElementError           Traceback (most recent call last)
UnsupportedLanguageElementError: could not parse the source code:

              .map(lambda _: tf.random_normal([bs, nd])))

This error may be avoided by creating the lambda in a standalone statement.


During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-2-b8c4c89fd469> in <lambda>(_)
     12 
     13   noise_ds = (tf.data.Dataset.from_tensors(0).repeat()
---> 14               .map(lambda _: tf.random_normal([bs, nd])))
     15 
     16   if just_noise:

AttributeError: module 'tensorflow' has no attribute 'random_normal'

I run from this URL: https://colab.research.google.com/github/tensorflow/gan/blob/master/tensorflow_gan/examples/colab_notebooks/tfgan_tutorial.ipynb#scrollTo=zEhgLuGo8OGc
Modified runtime to GPU, and started running the cells.

@RajeevAtla
Copy link

I think the method should be tf.random.normal instead of tf.random_normal.
I'll open a pull request.

@chinery
Copy link

chinery commented Sep 10, 2020

Sorry if I'm mistaken, but I believe both colab tutorials are written to use TensorFlow 1.x, and will not run with 2.x (which will be the default on colab). Notice both have tf.logging calls early on, which is removed in TensorFlow 2.x. I believe random_normal was the method name in 1.x also.

For a temporary fix, you can add the following lines to the start of the first code cell to get the colab to run.

!pip install tensorflow==1.15.0
!pip install tensorflow-probability==0.7.0

@caph1993
Copy link

Another alternative is to set tensorflow in compatibility mode adding tf = tf.compat.v1 after importing tf.

Notice that the tutorial imports tensorflow several times, so you must add that line after each import, or yet better, remove those unnecessary imports that overwrite the tf variable.

@SauravMaheshkar
Copy link

Please assign this to me.

I'd like to convert this introductory notebook into Keras.

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