I don't understand what my problem is. It should work, if only because its the standard autoenoder from the tensorflow documentation. this is the error
line 64, in call
decoded = self.decoder(encoded)
ValueError: Exception encountered when calling Autoencoder.call().
Invalid dtype: <property object at 0x7fb471cc1c60>
Arguments received by Autoencoder.call():
• x=tf.Tensor(shape=(32, 28, 28), dtype=float32)
and this is my code
(x_train, _), (x_test, _) = fashion_mnist.load_data()
x_train = x_train.astype('float32') / 255.
x_test = x_test.astype('float32') / 255.
print (x_train.shape)
print (x_test.shape)
class Autoencoder(Model):
def __init__(self, latent_dim, shape):
super(Autoencoder, self).__init__()
self.latent_dim = latent_dim
self.shape = shape
self.encoder = tf.keras.Sequential([
layers.Flatten(),
layers.Dense(latent_dim, activation='relu'),
])
self.decoder = tf.keras.Sequential([
layers.Dense(tf.math.reduce_prod(shape), activation='sigmoid'),
layers.Reshape(shape)
])
def call(self, x):
encoded = self.encoder(x)
print(encoded)
decoded = self.decoder(encoded)
print(decoded)
return decoded
shape = x_test.shape[1:]
latent_dim = 64
autoencoder = Autoencoder(latent_dim, shape)
autoencoder.compile(optimizer='adam', loss=losses.MeanSquaredError())
autoencoder.fit(x_train, x_train,
epochs=10,
shuffle=True,
validation_data=(x_test, x_test))
I tried to change the database and also tried different shapes