Error when checking input: expected dense_Dense1_input to have x dimension(s). but got array with shape y,z

Asked
Active3 hr before
Viewed126 times

6 Answers

inputerror
90%

I'm very new to Tensorflowjs and Tensorflow in general. I have some data, which is capacity used out of 100%, so a number between 0 and 100, and there are 5 hours per day these capacities are noted. So I have a matrix of 5 days, containing 5 percentages out of 100%.,Thanks for contributing an answer to Stack Overflow!, Safety when entering a spherical or one-way portal , Did anyone cross over to the mirror universe to find a loved one?

Your error comes from a mismatch of the size of the training and test data from one hand on the other hand by what is defined as the input of your model

model.add(tf.layers.dense({
   units: 1,
   inputShape: [5, 5]
}));
load more v
88%

I'm getting an error returned: Error when checking input: expected dense_Dense1_input to have 3 dimension(s). but got array with shape 5,5. So I suspect I'm entering or mapping my data incorrectly in some way.,I'm very new to Tensorflowjs and Tensorflow in general. I have some data, which is capacity used out of 100%, so a number between 0 and 100, and there are 5 hours per day these capacities are noted. So I have a matrix of 5 days, containing 5 percentages out of 100%.,The inputShape is your input dimension. Here it is 5, because each features is an array of size 5. ,so now the timedistributed layer flattens to 49 inputs(looks like a bias input is included) to the final dense layer into a single output.

I have the following model:

const model = tf.sequential();
model.add(tf.layers.dense({
   units: 1,
   inputShape: [5, 5]
}));
model.compile({
   loss: 'binaryCrossentropy',
   optimizer: 'sgd'
});

// Input data
// Array of days, and their capacity used out of 
// 100% for 5 hour period
const xs = tf.tensor([
   [11, 23, 34, 45, 96],
   [12, 23, 43, 56, 23],
   [12, 23, 56, 67, 56],
   [13, 34, 56, 45, 67],
   [12, 23, 54, 56, 78]
]);

// Labels
const ys = tf.tensor([
   [1],
   [2],
   [3],
   [4],
   [5]
]);

// Train the model using the data.
model.fit(xs, ys).then(() => {
   model.predict(tf.tensor(5)).print();
}).catch((e) => {
   console.log(e.message);
});
load more v
72%

Am getting this error, Error when checking input: expected lstm_40_input to have 3 dimensions, but got array with shape (1191, 26),ValueError: Error when checking input: expected lstm_13_input to have 3 dimensions, but got array with shape (1, 10),ValueError: Error when checking input: expected lstm_10_input to have 3 dimensions, but got array with shape (413378, 244),ValueError: Error when checking input: expected reshape_4_input to have 4 dimensions, but got array with shape (0, 1)

model = Sequential()
model.add(LSTM(24, input_shape = (1200, 19), return_sequences = True, implementation = 2))
model.add(TimeDistributed(Dense(1)))
model.add(AveragePooling1D())
model.add(Dense(2, activation = 'softmax'))
model.compile(loss = categorical_crossentropy, optimizer = RMSprop(lr = .01))
model.fit(train_x, train_y, epochs = 100, batch_size = 6000, verbose = 1, validation_data = (test_x, test_y))
load more v
65%

Error when checking input: expected dense_Dense1_input to have x dimension(s). but got array with shape y,z ,Error when checking input: expected dense_Dense1_input to have 3 dimension(s). but got array with shape 3,4, expected dense dense1 input to have shape a but got array with shape b ,关于tensorflow - 检查目标 : expected dense_Dense2 to have shape x, 时出错,但得到形状为 y 的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63976057/

这是我在 tensorflow 中的第一步。
创意
有一些数字模式(数字数组: Pattern = number[] )。以及与此模式对应的类别(从 0 到 2 的数字: Category = 0 | 1 | 2 )。我遵循了结构数据:xs = Pattern[] , ys = Category[] .
例如:

xs = [
   [1, 2, 3, 4],
   [5, 6, 7, 8], ..., [9, 10, 11, 12]
];
ys = [1, 0, ..., 2];
load more v
75%


const model = tf.sequential();
model.add(tf.layers.dense({
   units: 1,
   inputShape: [5, 5]
}));
model.compile({
   loss: 'binaryCrossentropy',
   optimizer: 'sgd'
});

// Input data
// Array of days, and their capacity used out of 
// 100% for 5 hour period
const xs = tf.tensor([
   [11, 23, 34, 45, 96],
   [12, 23, 43, 56, 23],
   [12, 23, 56, 67, 56],
   [13, 34, 56, 45, 67],
   [12, 23, 54, 56, 78]
]);

// Labels
const ys = tf.tensor([
   [1],
   [2],
   [3],
   [4],
   [5]
]);

// Train the model using the data.
model.fit(xs, ys).then(() => {
   model.predict(tf.tensor(5)).print();
}).catch((e) => {
   console.log(e.message);
});
load more v
40%

Ошибка при проверке ввода: ожидалось, что dense_input будет иметь форму (21,), но получил массив с формой (1,) , Ошибка при проверке ввода: ожидалось, что conv2d_1_input будет иметь форму (3, 32, 32), но получил массив с формой (32, 32, 3) , ValueError: ошибка при проверке ввода: ожидалось, что lstm_1_input будет иметь 3 измерения, но получил массив с формой (10, 1) , Ошибка при проверке ввода модели: ожидалось, что lstm_1_input будет иметь 3 измерения, но получил массив с формой (339732, 29)

У меня есть следующая модель:

const model = tf.sequential();
model.add(tf.layers.dense({
   units: 1,
   inputShape: [5, 5]
}));
model.compile({
   loss: 'binaryCrossentropy',
   optimizer: 'sgd'
});

// Input data
// Array of days, and their capacity used out of 
// 100% for 5 hour period
const xs = tf.tensor([
   [11, 23, 34, 45, 96],
   [12, 23, 43, 56, 23],
   [12, 23, 56, 67, 56],
   [13, 34, 56, 45, 67],
   [12, 23, 54, 56, 78]
]);

// Labels
const ys = tf.tensor([
   [1],
   [2],
   [3],
   [4],
   [5]
]);

// Train the model using the data.
model.fit(xs, ys).then(() => {
   model.predict(tf.tensor(5)).print();
}).catch((e) => {
   console.log(e.message);
});
load more v

Other "input-error" queries related to "Error when checking input: expected dense_Dense1_input to have x dimension(s). but got array with shape y,z"