Keras is now part of tensorflow 2.0, in past you will have to install with pip like other packages
I have two question:
(1) The question about importing some subpackages inside tensorflow.keras.
(2) How to differentiate between the packages installed by 'pip install' and 'conda install'.(under windows)
I am using anaconda with tensorflow 2.0.0. I am trying to import package like:
import tensorflow.keras.utils.np_utils
However, the error shown that:
---------------------------------------------------------------------------
> ModuleNotFoundError Traceback (most recent call
> last) <ipython-input-2-ee1bc59a14ab> in <module>
> ----> 1 import tensorflow.keras.utils.np_utils
>
> ModuleNotFoundError: No module named 'tensorflow.keras.utils.np_utils'
I am confused about why this is happening, I install the tensorflow with command:
conda install tensorflow==2.0.0
from Anaconda prompt.
Yes, I know the anaconda should have already had all the data science package inside it, the reason that I uninstall tensorflow provided by anaconda and reinstall it was before using anaconda, I had Python installed on my PC, since anaconda came with another Python(if I can think in this way :), I just got confused about the differences between packages installed by 'pip install' command and 'conda install' command, so I kept trying uninstalling and reinstalling them... Just want to see in which case I can use them in jupyter notebook and in which case I can use them in Pycharm.
Here is some examples of the things I am confused:
If I install a package P with 'pip' command, in the command
line(not anaconda prompt), when I open jupyter notebook from the
virtual environment that I created in anaconda, can I import this
P?
If have installed tensorflow two times, one time from command line
and one time from anaconda prompt, when I use the virtual environment of anaconda and import tensorflow, which one is it actually calling?
If possible, hope to get sulution to 1) and maybe a simple explanation to question (2), sorry about posting too many, but I am just too confused.
Thanks a lot :)
from tensorflow.keras.utils import to_categorical
Keras is now part of tensorflow 2.0, in past you will have to install with pip like other packages
from tensorflow.keras import utils
Then try to replace:
np_utils.to_categorical
With:
utils.to_categorical
Sorry if this is very delayed hope you are fine!
from tensorflow.keras.utils import to_categorical
to_categorical()
OR
from tensorflow.keras import utils
utils.to_categorical