0

The autocomplete function of VS Code 1.41.1 does not work for example for

from tensorflow.keras import layers

(for tensorflow version 1.14.0) but it works for

from tensorflow.python.keras import layers

So what is the exact difference? Why does it work in the latter case? And is it always safe to replace the first method with the second, meaning it produces identical behavior by using the exact same methods?

RolleRugu
  • 233
  • 2
  • 11
  • 1
    So your question is why the autocomplete doesn't work? Not that you're having trouble using `tensorflow.keras.layers` right? And for the difference, have a look at [this](https://stackoverflow.com/questions/58279628/what-is-the-difference-between-tf-keras-and-tf-python-keras) – thushv89 Jan 20 '20 at 21:50
  • You are right. I am able to use `tf.keras.layers` as well as `tf.python.keras.layers`. The difference is, that autocorrect works just in the latter case correctly. It seems to be a common issue: https://www.youtube.com/watch?v=m49LAkcij0c Thank you for the link to the topic about `tf.python`. – RolleRugu Jan 21 '20 at 08:28

2 Answers2

0

So, thanks to thushv89 and some additional research I found some kind of explanation and solution:

https://github.com/microsoft/python-language-server/issues/818

The way TensorFlow handels imports cannot be read by VS Code easily. Using tf.python.keras is a work around, but definitely not recommended. Other ways to solve this issue are described here:

https://github.com/tensorflow/tensorflow/issues/32982

RolleRugu
  • 233
  • 2
  • 11
0

This issue is resolved when using tensorflow version 2.2.