Wednesday, November 21, 2018

Notes about Eager Execution using Keras

About model inputs
If the model is created using Sequential, the inputs can be numpy ndarray. However, if you compose the model using Keras layers like the MNISTModel in the Guide for Eager Execution, the inputs need to be Tensorflow Tensors. You can use tf.constant() to convert numpy arrays to Tensors. However, some types of numpy array are not accepted by tf.constant(). For example, 'a = np.random.randint(0, 10, (2,3)) % 5' does not work with tf.constant(). You need to do a type conversion a=a.astype(np.int32) before calling tf.constant.




No comments: