It is my first post, hope formating code function, when not, sorry! I made first steps with tensorflow for around 5 weeks. Now I want to try out tensorflow 2.0. I know I can work with 1.13. But simple want to get 2.0 running.

What I did installed tensorflow alpha:

pip install tensorflow==2.0.0-alpha0

Ok, also cuda 10., but I don't come to this point where cuda is necessary. It lookes now like this :

(tensor) [email protected]:~/venv$ pip list
Package              Version             
-------------------- --------------------
absl-py              0.7.1               
astor                0.7.1               
enum34               1.1.6               
gast                 0.2.2               
google-pasta         0.1.5               
grpcio               1.20.0              
h5py                 2.9.0               
Keras                2.2.4               
Keras-Applications   1.0.7               
Keras-Preprocessing  1.0.9               
Markdown             3.1                 
matlab               0.1                 
mock                 2.0.0               
numpy                1.16.2              
pandas               0.24.2              
pandas-ml            0.6.1               
pbr                  5.1.3               
pip                  19.0.3              
protobuf             3.7.1               
python-dateutil      2.8.0               
pytz                 2019.1              
PyYAML               5.1                 
scipy                1.2.1               
setuptools           41.0.0              
six                  1.12.0              
tb-nightly           1.14.0a20190301     
tensorflow-gpu       2.0.0a0             
termcolor            1.1.0               
tf-estimator-nightly 1.14.0.dev2019030115
Werkzeug             0.15.2              
wheel                0.33.1              
wrapt                1.11.1  

But when I want to make little sample with tensorflow 2.0 i get always error cause of keras. Simple when I want to load mist data, or for example

model = tf.keras.models.Sequential()

Error is always

Undefined variable from input:keras

Where is keras ?? The code is not rocket science, only a test code run, maybe to stupid to put here at forum right tabs.

import datetime
from datetime import datetime , timedelta
from dateutil import relativedelta
from keras.layers import Dense,Conv2D, Flatten, MaxPooling2D, Dropout
from  pandas_ml import ConfusionMatrix
from tensorflow.python.client import device_lib

import tensorflow as tf

if __name__ == '__main__':
    print (tf.version)   
    # shows always Undefined variable from input:keras
    mnist = tf.keras.datasets.mnist

    '''
    model = tf.keras.models.Sequential()
    model.add(tf.keras.layers.Conv2D(30,kernel_size=(3,3), activation="relu",input_shape=(28,28,1) ))
    model.add(tf.keras.layers.MaxPool2D(pool_size=(2,2)) ) # , strides, padding, data_format)) 
    '''

Aso you see here, 2.0 is used, but can not run cause of error Undefined variable from input:keras.

The print(tf.version) shows, that tensorflow 2.0 is there:

Thanks a lot. checkt also

import datetime
from datetime import datetime , timedelta
from dateutil import relativedelta
import gzip
import zipfile
import numpy as np
from keras.utils import to_categorical
from keras.layers import Dense,Conv2D, Flatten, MaxPooling2D, Dropout
from  pandas_ml import ConfusionMatrix
from tensorflow.python.client import device_lib

import tensorflow as tf

if __name__ == '__main__':
    print (tf.version)   
    # shows always Undefined variable from input:keras
    mnist = tf.keras.datasets.mnist

    '''
    model = tf.keras.models.Sequential()
    model.add(tf.keras.layers.Conv2D(30,kernel_size=(3,3), activation="relu",input_shape=(28,28,1) ))
    model.add(tf.keras.layers.MaxPool2D(pool_size=(2,2)) ) # , strides, padding, data_format)) 
    '''

I expect ,that for example model = tf.keras.models.Sequential() will not end in error Undefined variable from input:keras.

1 Answers

0
gabriel.ibagon On

Your code mixes the TensorFlow version of Keras (which was installed with tensorflow-2.0) and the stand-alone Keras. Change your inputs from:

from keras.utils import to_categorical
from keras.layers import Dense,Conv2D, Flatten, MaxPooling2D, Dropout

to

from tensorflow.keras.utils import to_categorical
from tensorflow.keras.layers import Dense,Conv2D, Flatten, MaxPooling2D, Dropout