I have DNA data as input to Keras, DNA data is an one-hot encoded array it such that each DNA sequence is 4 channels (one for each type of nucleotide). The one-hot matrix is in matlab and has the dimension: (4,400,100) 100 samples.
first matlab has dimensions row* cloumn * slice (4, 400, 100) but I change dimensions to get (100, 4, 400) like python format
import scipy.io
x = scipy.io.loadmat('x.mat')
x2 = x['x']
x2 = np.ascontiguousarray(x2.T)
x2 = np.ascontiguousarray(x2.swapaxes(1, 2))
X_train =x2
y = scipy.io.loadmat('y.mat')
y2 = y['y']
Y_train = np_utils.to_categorical(y2, 2)
Now the X_train shape is: (100, 4, 400) Y_train shape is (100, 2)
2)
And my model is Conv1D looks like this:
model = Sequential()
model.add(Conv1D(32, 3, activation='relu', input_shape=(4, 400)))
model.add(MaxPooling1D(2))
model.add(Dropout(0.5))
model.add(Dense(128, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.fit(X_train, Y_train, batch_size=16, epochs=10)
Error massage
Traceback (most recent call last): in <module>
model.fit(X_train, Y_train, batch_size=16, epochs=5)
in _standardize_user_data
exception_prefix='target')
in _standardize_input_data
str(array.shape))
ValueError: Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (100, 2)