Closed schneider128k closed 4 years ago
Hi --- whoops, the readme code is slightly out of date! We've switched over to using tensorflow.keras
which has some slight differences in how the Layer class is treated.
This can be fixed by using from tensorflow import keras
instead of import keras
.
E.g.:
from tensorflow import keras
import mdn
N_HIDDEN = 15 # number of hidden units in the Dense layer
N_MIXES = 10 # number of mixture components
OUTPUT_DIMS = 2 # number of real-values predicted by each mixture component
model = keras.Sequential()
model.add(keras.layers.Dense(N_HIDDEN, batch_input_shape=(None, 1), activation='relu'))
model.add(mdn.MDN(OUTPUT_DIMS, N_MIXES))
model.compile(loss=mdn.get_mixture_loss_func(OUTPUT_DIMS,N_MIXES), optimizer=keras.optimizers.Adam())
model.summary()
If you want to use regular keras, the previous version (v0.2.3) still supports it and is available on PyPI.
Thanks a lot for your help! The above code works perfectly.
I get an error message when trying to use the code below How to use in the readme file.
I am using colab with Python 3.6.9 and TensorFlow 1.15.0.
prints out
Python 3.6.9
andprints out
1.15.0
.I have installed the latest version of the keras-mdn-layer package with
!pip install keras-mdn-layer
Code (copied from the readme file without any changes):
Error message :
What am I missing?