ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,)Scikit learn (Python 3.5): Do I need to import a library to make this work?ValueError: Error when checking input: expected time_distributed_46_input to have 5 dimensions, but got array with shape (200, 200, 3)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (393613, 50)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (10, 1)Tensorflow keras with tf dataset inputValueError: Error when checking target: expected output to have shape (1,) but got array with shape (2,)LSTM Nerual Network Input/Output dimensions errorKeras batch_size problem when using model.fit in custom layersNeural Network classificationValueError: Error when checking input: expected conv1d_81_input to have shape (177, 100) but got array with shape (1, 177)
Mapping arrows in commutative diagrams
Why is my log file so massive? 22gb. I am running log backups
What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?
What to wear for invited talk in Canada
What happens when a metallic dragon and a chromatic dragon mate?
Does the average primeness of natural numbers tend to zero?
Is it possible to make sharp wind that can cut stuff from afar?
Einstein metrics on spheres
Crop image to path created in TikZ?
Finding files for which a command fails
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
Check if two datetimes are between two others
Denied boarding due to overcrowding, Sparpreis ticket. What are my rights?
Email Account under attack (really) - anything I can do?
How to move the player while also allowing forces to affect it
"My colleague's body is amazing"
When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?
Need help identifying/translating a plaque in Tangier, Morocco
Is Fable (1996) connected in any way to the Fable franchise from Lionhead Studios?
Can I find out the caloric content of bread by dehydrating it?
How can I fix this gap between bookcases I made?
Patience, young "Padovan"
"listening to me about as much as you're listening to this pole here"
Can I legally use front facing blue light in the UK?
ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,)
Scikit learn (Python 3.5): Do I need to import a library to make this work?ValueError: Error when checking input: expected time_distributed_46_input to have 5 dimensions, but got array with shape (200, 200, 3)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (393613, 50)ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (10, 1)Tensorflow keras with tf dataset inputValueError: Error when checking target: expected output to have shape (1,) but got array with shape (2,)LSTM Nerual Network Input/Output dimensions errorKeras batch_size problem when using model.fit in custom layersNeural Network classificationValueError: Error when checking input: expected conv1d_81_input to have shape (177, 100) but got array with shape (1, 177)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:
import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd
!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls
batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50
train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')
x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']
x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']
Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)
model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])
model.fit(Train, epochs=epochs, steps_per_epoch=600)I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?
Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.
python tensorflow machine-learning google-colaboratory tf.keras
add a comment |
I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:
import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd
!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls
batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50
train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')
x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']
x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']
Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)
model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])
model.fit(Train, epochs=epochs, steps_per_epoch=600)I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?
Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.
python tensorflow machine-learning google-colaboratory tf.keras
add a comment |
I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:
import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd
!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls
batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50
train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')
x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']
x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']
Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)
model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])
model.fit(Train, epochs=epochs, steps_per_epoch=600)I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?
Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.
python tensorflow machine-learning google-colaboratory tf.keras
I'm testing out tf.keras with tf.data, so I can do minibatch optimization. I'm using the MNIST dataset, and I'm running the code in Google Colab. However, when I try to train the network, I always get this error:ValueError: Error when checking input: expected dense_18_input to have shape (784,) but got array with shape (1,). Here is my code:
import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd
!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls
batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50
train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')
x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']
x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']
Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)
model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])
model.fit(Train, epochs=epochs, steps_per_epoch=600)I don't know what the problem is. I think my dimensions are correct, and I can't see any other problem. How do I fix this problem?
Edit: I’ve looked more/tested things to find the answer, but I can’t find anything that works. I have no idea at all what the problem could be.
import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd
!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls
batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50
train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')
x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']
x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']
Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)
model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])
model.fit(Train, epochs=epochs, steps_per_epoch=600)import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import pandas as pd
!git clone https://github.com/DanorRon/my_repo
%cd my_repo
!ls
batch_size = 100
epochs = 10
alpha = 0.01
lambda_ = 0.01
h1 = 50
train = pd.read_csv('/content/sample_data/my_repo/mnist_train.csv.zip')
test = pd.read_csv('/content/sample_data/my_repo/mnist_test.csv.zip')
x_train = train.loc[:, '1x1':'28x28']
y_train = train.loc[:, 'label']
x_test = test.loc[:, '1x1':'28x28']
y_test = test.loc[:, 'label']
Train = tf.data.Dataset.from_tensor_slices((x_train, y_train))
Train.batch(batch_size).repeat(10).shuffle(1000)
model = tf.keras.Sequential()
model.add(layers.Dense(784, input_shape=(784,)))
model.add(layers.Dense(h1, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(layers.Dense(10, activation='softmax', kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.compile(optimizer=tf.train.AdamOptimizer(alpha),
loss = 'categorical_crossentropy',
metrics = ['accuracy'])
model.fit(Train, epochs=epochs, steps_per_epoch=600)python tensorflow machine-learning google-colaboratory tf.keras
python tensorflow machine-learning google-colaboratory tf.keras
edited Mar 23 at 15:16
Ronan Venkat
asked Mar 22 at 1:37
Ronan VenkatRonan Venkat
4415
4415
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data()Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api withtensorflow.keras.
– david
Mar 25 at 2:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291653%2fvalueerror-error-when-checking-input-expected-dense-18-input-to-have-shape-78%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data()Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api withtensorflow.keras.
– david
Mar 25 at 2:24
add a comment |
I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data()Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api withtensorflow.keras.
– david
Mar 25 at 2:24
add a comment |
I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).
I guess maybe you should split x_train and y_train from Train, and rewrite model.fit as model.fit(x_train, y_train, epochs=epochs, steps_per_epoch=600).
answered Mar 22 at 2:22
daviddavid
597
597
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data()Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api withtensorflow.keras.
– david
Mar 25 at 2:24
add a comment |
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data()Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api withtensorflow.keras.
– david
Mar 25 at 2:24
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Is there a way to fix the problem without splitting the dataset?
– Ronan Venkat
Mar 22 at 13:13
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
Also, how do I break the dataset apart? I can’t find anything on the docs.
– Ronan Venkat
Mar 22 at 16:40
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.– david
Mar 25 at 2:24
from keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() Sorry, I haven't used the dataset in csv form. Generally, I use the api of keras. It has the same api with tensorflow.keras.– david
Mar 25 at 2:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291653%2fvalueerror-error-when-checking-input-expected-dense-18-input-to-have-shape-78%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown