简体   繁体   中英

Set input shape of model in keras

I had saw other similar question on tensor flow but didn't match my problem.

Model:

# picture size
img_row = 128
img_col = 647
shape = (img_row, img_col)

img = Input(input_shape)
...

with result 模型

Data:

There has 1000 datas and each with shape (128, 647), and its a column of Dataframe df. Therefore, size result and data preview are as follow: 在此处输入图片说明 在此处输入图片说明

Problem

The problem is: when I pass the Data to Model, some size error occured.

train_history = model.fit(  x = df["data"],
                            y = df["genre_idx"],
                            validation_split = 0.1,
                            epochs = 30,
                            batch_size = 200,
                            verbose = 2
                         )

And error message are as follow:

Error when checking input: expected input_79 to have 3 dimensions, but got array with shape (1000, 1)

It might be a low question, but I didn't figure out what is the main problem of this situation and how to solve it.

You need to give it as a single ndarray which you can extract using the .values property of the data frame. The expected shape for the input is (1000, 128, 647) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM