Closed OscarRL closed 6 years ago
I have added one hot function to the Keras backend too. Would you like to submit a PR so that fast mode works on both backends?
Yes, srry.. I didn't see it
https://keras.io/backend/#backend-functions
def one_hot(self, seq, num_classes): return K.one_hot(K.reshape(K.cast(seq, "int32"), (-1, 1)), num_classes)
Works on the 2 backends for me on gpu
Yes. Can you make a PR to qlearning4k to use K.one_hot?
Look the pull request
Tensorflow now provides a native one_hot function making the fast implementation suitable with tensorflow
https://www.tensorflow.org/versions/r0.11/api_docs/python/array_ops.html#one_hot
Ex: def one_hot_tensor(self, seq, num_classes): import tensorflow as T return T.one_hot(K.reshape(T.cast(seq, T.int32), (-1, 1)), num_classes)