I have a 3D Input (Samples, Steps, Features). So each sample has a chain of steps that have different features. Now, I want a 2D Output (Samples, Steps) where I have samples and at each step of the sample a 0 or a 1 calculated from the model.
So I think it is a sequential binary classification problem. I have some difficult to define the model, especially the output layer.
Here are the shapes of numpy arrays:
x_train.shape
# (200, 1657, 669)
x_test.shape
# (41, 1657, 669)
y_train.shape
# (200, 1657)
y_test.shape
# (41, 1657)
I tried this model but the output was not the one I was expecting
n_residues, n_features, n_outputs = trainX.shape[1], trainX.shape[2], trainy.shape[1]
model = Sequential()
model.add(Conv1D(filters=64, kernel_size=3, activation='relu', input_shape=(n_residues,n_features)))
model.add(Conv1D(filters=64, kernel_size=3, activation='relu'))
model.add(Dropout(0.1))
model.add(MaxPooling1D(pool_size=2))
model.add(Flatten())
model.add(Dense(100, activation='relu'))
model.add(Dense(n_outputs, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# fit network
model.fit(trainX, trainy, epochs=epochs, batch_size=batch_size, verbose=verbose)
m_classes = model.predict_classes(x_test, verbose=0)
print(m_classes)
[ 36 36 59 32 16 32 36 804 1047 16 16 36 32 36
36 36 16 16 16 16 16 16 36 16 36 36 36 16
59 36 36 36 16 16 16 804 16 16 16 36 36]
The output is a 41 long vector for the 41 samples in the test set with classes 0 -1657 I assume.
My desired output for the test set would be 41 binary vectors that are 1657 long.
Thanks!