'How to fix the 'ValueError: input tensor must have rank 3'?
Currently I'm trying to run a Autoencoder in combination with CNN for IRIS data, but after a search on Google and Stackoverflow I wasn't able to find the solution for my problem. Totally I have many problems with data dimensions in the first layer of all networks. Please give me good resources to understand it.
x =tf.expand_dims(X_scaled, axis=-1)
y_train=np_utils.to_categorical(y,num_classes=3)
print("Shape of y_train",y_train.shape)#(150,3)
print(x.shape)#(150,4,1)
inputdata = keras.Input(x.shape,name="data")
encoding_layer1 = layers.Conv1D(16, 3, activation='relu', padding='same')(inputdata)
encoding_layer1 = layers.MaxPooling1D(2, padding='same')(encoding_layer1 )
encoding_layer2 = layers.Conv1D(8, 3, activation='relu', padding='same')(encoding_layer1 )
encoding_layer2 = layers.MaxPooling1D(2, padding='same')(encoding_layer2)
bottleneck= layers.Conv1D(4, 3, activation='relu', padding='same')(encoding_layer2)
decoding_layer2 =layers.BatchNormalization()(decoding_layer2)
decoding_layer3=layers.Conv1DTranspose(8,3, strides=2, activation='relu', padding='same')
(decoding_layer2)
decoding_layer4 =layers.BatchNormalization()(decoding_layer3)
# d =layers.Conv1DTranspose(16,3, activation='relu', padding='same')(d)
decoded =layers.Conv1D(16, 3, activation='sigmoid', padding='same')(decoding_layer4)
model = keras.Model(inputs=inputdata, outputs=decoded )
autoencoder = keras.Model(inputdata, decoded)
autoencoder.compile(optimizer='adam', loss="mse")
autoencoder.summary()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
