python - Wrong number of dimensions. Keras -


i'm having troubles grasping shape input first layer of network. architecture:

    # model hyperparameters     filter_sizes = [1, 2, 3, 4, 5]     num_filters = 10     dropout_prob = [0.5, 0.8]     hidden_dims = 50      model_input = input(shape=(x.shape[0], x.shape[1]))     z = model_input     z = dropout(0.5)(z)      # convolutional block     conv_blocks = []     fz in filter_sizes:         conv = convolution1d(filters=num_filters,                              kernel_size=fz,                              padding="valid",                              activation="relu",                              strides=1)(z)         conv = maxpooling1d(pool_size=2)(conv)         conv = flatten()(conv)         conv_blocks.append(conv)      z = concatenate()(conv_blocks) if len(conv_blocks) > 1 else conv_blocks[0]      z = dropout(dropout_prob[1])(z)     z = dense(hidden_dims, activation="relu")(z)     model_output = dense(3, activation="softmax")(z)      model = model(model_input, model_output)     model.fit(x[train], to_categorical(y[train], num_classes=3))    valueerror: error when checking input: expected input_1 have 3 dimensions, got array shape (12547, 261) 

this how data looks like:

array([[ 1,  2,  3, ...,  0,  0,  0],        [ 5,  6,  7, ...,  0,  0,  0],        [15, 10,  4, ...,  0,  0,  0],        ...,        [ 5,  6,  8, ...,  0,  0,  0],        [11, 10, 14, ...,  0,  0,  0],        [14,  8,  8, ...,  0,  0,  0]]) 

i have 14640 samples 261 dimensions

as error says it's shaping problem shape of input (model_input) provided should match input shape of data feed in model.fit

recheck shapes using: from keras import backend k k.shape(input _tensor) if it's tensor or np.shape() if it's numpy array. if shapes don't match(and won't)use function k.reshape fore more see keras/backend api


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -