Categories
Misc

Model was constructed with shape (None, 1061, 4) for input … but it was called on an input with incompatible shape (None, 4).

EDIT: SOLVED. Thank you all so much!

I’m building a neural network where my inputs are 2d arrays, each representing one day of data.

I have a container array that holds 7 days’ arrays, each of which has 1,061 4×1 arrays. That sounds very confusing to me so here’s a diagram:

container array [ matrix 1 [ vector 1 [a, b, c, d] ... vector 1061 [e, f, g, h] ] ... matrix 7 [ vector 1 [i, j, k, l] ... vector 1061 [m, n, o, p] ] ] 

In other words, the container’s shape is (7, 1061, 4).

That container array is what I pass to the fit method for “x”. And here’s how I construct the network:

input_shape = (1061, 4) network = Sequential() network.add(Input(shape=input_shape)) network.add(Dense(2**6, activation="relu")) network.add(Dense(2**3, activation="relu")) network.add(Dense(2, activation="linear")) network.compile( loss="mean_squared_error", optimizer="adam", ) 

The network compiles and trains, but I get the following warning while training:

WARNING:tensorflow:Model was constructed with shape (None, 1061, 4) for input KerasTensor(type_spec=TensorSpec(shape=(None, 1061, 4), dtype=tf.float32, name=’input_1′), name=’input_1′, description=”created by layer ‘input_1′”), but it was called on an input with incompatible shape (None, 4).

I double-checked my inputs, and indeed there are 7 arrays of shape (1061, 4). What am I doing wrong here?

Thank you in advance for the help!

submitted by /u/bens_scraper
[visit reddit] [comments]

Leave a Reply

Your email address will not be published.