I want to save the encoded part just before decoder stage in autoencoder model of Keras with Tensorflow backend.
For instance;
encoding_dim = 210
input_img = Input(shape=(5184,))
encoded = Dense(2592, activation='relu')(input_img)
encoded1 = Dense(encoding_dim, activation='relu')(encoded)
decoded = Dense(encoding_dim, activation='relu')(encoded1)
decoded = Dense(5184, activation='sigmoid')(decoded)
I want to save the encoded1
as csv file after the autoencoder training. Suppose the output of Dense
will be (nb_samples, output_dim)
.
Thank you
Try:
autoencoder = Model(input_img, decoded)
encoder = Model(input_img, encoded1)
autoencoder.compile(loss=my_loss, optimizer=my_optimizer)
autoencoder.fit(my_data, my_data, .. rest of fit params)
numpy.savetxt("encoded1.csv", encoder.predict(x), delimiter=",")
Moreover - I don't know what kind of data do you have but I advise you to use linear
activation is a last layer and mse
loss function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With