ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]Keras AttributeError: 'list' object has no attribute 'ndim'LSTM with Keras: Input 'ref' of 'Assign' Op requires l-value inputError while doing reshapeRunning Tensorflow undefined symbol: PyClass_TypeError executing rnn model . How to fix it?Why am I getting Keras shape mismatch?Keras batch_size problem when using model.fit in custom layersAttributeError: 'Sequential' object has no attribute 'total_loss''Tensor' object has no attribute 'ndim'
Remaining in the US beyond VWP admission period
How do I use NEC PC-6001 .p6 or .cas files?
What can we do about our 9 month old putting fingers down his throat?
Opportunity profits vs. opportunity costs
How do I delete cookies from a specific site?
What are the solutions of this Diophantine equation?
My Friend James
How to interpret or parse this confusing 'NOT' and 'AND' legal clause
How do German speakers decide what should be on the left side of the verb?
Types of tablet... a tablet secretion
"syntax error near unexpected token" after editing .bashrc
Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?
What does it mean to count a group of numbers with their multiplicity?
Why would one hemisphere of a planet be very mountainous while the other is flat?
Global variables and information security
How should Thaumaturgy's "three times as loud as normal" be interpreted?
What exactly is Apple Cider
Balm of the Summer Court fey energy dice usage limits
Why did Boris Johnson call for new elections?
What are the map units that WGS84 uses?
What do English-speaking kids call ice-cream on a stick?
How do I anonymously report the Establishment Clause being broken?
What are some countries where you can be imprisoned for reading or owning a Bible?
How does the UK House of Commons think they can prolong the deadline of Brexit?
ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]
Keras AttributeError: 'list' object has no attribute 'ndim'LSTM with Keras: Input 'ref' of 'Assign' Op requires l-value inputError while doing reshapeRunning Tensorflow undefined symbol: PyClass_TypeError executing rnn model . How to fix it?Why am I getting Keras shape mismatch?Keras batch_size problem when using model.fit in custom layersAttributeError: 'Sequential' object has no attribute 'total_loss''Tensor' object has no attribute 'ndim'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am new to Tensorflow and trying to work on it using the sample code below:
def build_model():
model = keras.Sequential([
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)
model.compile(loss='mean_squared_error',
optimizer=optimizer,
metrics=['mean_absolute_error', 'mean_squared_error'])
return model
model = build_model()
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
The training_dataset is as below with 179 rows:
features:[29225 29259 29210 29220] Label:2
features:[29220 29236 29201 29234] Label:1
features:[29234 29241 29211 29221] Label:2
features:[29221 29224 29185 29185] Label:2
features:[29185 29199 29181 29191] Label:2
features:[29191 29195 29171 29195] Label:1
features:[29195 29228 29189 29225] Label:1
features:[29225 29236 29196 29199] Label:2
features:[29199 29222 29197 29218] Label:1
features:[29218 29235 29207 29224] Label:1
features:[29224 29244 29223 29234] Label:1
features:[29234 29247 29222 29240] Label:1
features:[29240 29264 29240 29263] Label:1
features:[29263 29267 29234 29237] Label:1
features:[29237 29270 29232 29267] Label:0
features:[29267 29270 29252 29253] Label:2
And I got the following error when running it:
"ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]".
Can anyone advise on how to fix it?
Traceback (most recent call last):
File "ML.py", line 145, in <module>
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 851, in fit
initial_epoch=initial_epoch)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_generator.py", line 191, in model_iteration
batch_outs = batch_function(*batch_data)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1175, in train_on_batch
x, y, sample_weight=sample_weight, class_weight=class_weight)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2289, in _standardize_user_data
self._set_inputs(cast_inputs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/checkpointable/base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2529, in _set_inputs
outputs = self.call(inputs, training=training)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 233, in call
inputs, training=training, mask=mask)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 254, in _call_and_compute_mask
layer._maybe_build(x)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1591, in _maybe_build
self.input_spec, inputs, self.name)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py", line 139, in assert_input_compatibility
str(x.shape.as_list()))
ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]
python tensorflow
add a comment |
I am new to Tensorflow and trying to work on it using the sample code below:
def build_model():
model = keras.Sequential([
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)
model.compile(loss='mean_squared_error',
optimizer=optimizer,
metrics=['mean_absolute_error', 'mean_squared_error'])
return model
model = build_model()
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
The training_dataset is as below with 179 rows:
features:[29225 29259 29210 29220] Label:2
features:[29220 29236 29201 29234] Label:1
features:[29234 29241 29211 29221] Label:2
features:[29221 29224 29185 29185] Label:2
features:[29185 29199 29181 29191] Label:2
features:[29191 29195 29171 29195] Label:1
features:[29195 29228 29189 29225] Label:1
features:[29225 29236 29196 29199] Label:2
features:[29199 29222 29197 29218] Label:1
features:[29218 29235 29207 29224] Label:1
features:[29224 29244 29223 29234] Label:1
features:[29234 29247 29222 29240] Label:1
features:[29240 29264 29240 29263] Label:1
features:[29263 29267 29234 29237] Label:1
features:[29237 29270 29232 29267] Label:0
features:[29267 29270 29252 29253] Label:2
And I got the following error when running it:
"ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]".
Can anyone advise on how to fix it?
Traceback (most recent call last):
File "ML.py", line 145, in <module>
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 851, in fit
initial_epoch=initial_epoch)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_generator.py", line 191, in model_iteration
batch_outs = batch_function(*batch_data)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1175, in train_on_batch
x, y, sample_weight=sample_weight, class_weight=class_weight)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2289, in _standardize_user_data
self._set_inputs(cast_inputs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/checkpointable/base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2529, in _set_inputs
outputs = self.call(inputs, training=training)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 233, in call
inputs, training=training, mask=mask)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 254, in _call_and_compute_mask
layer._maybe_build(x)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1591, in _maybe_build
self.input_spec, inputs, self.name)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py", line 139, in assert_input_compatibility
str(x.shape.as_list()))
ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]
python tensorflow
add a comment |
I am new to Tensorflow and trying to work on it using the sample code below:
def build_model():
model = keras.Sequential([
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)
model.compile(loss='mean_squared_error',
optimizer=optimizer,
metrics=['mean_absolute_error', 'mean_squared_error'])
return model
model = build_model()
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
The training_dataset is as below with 179 rows:
features:[29225 29259 29210 29220] Label:2
features:[29220 29236 29201 29234] Label:1
features:[29234 29241 29211 29221] Label:2
features:[29221 29224 29185 29185] Label:2
features:[29185 29199 29181 29191] Label:2
features:[29191 29195 29171 29195] Label:1
features:[29195 29228 29189 29225] Label:1
features:[29225 29236 29196 29199] Label:2
features:[29199 29222 29197 29218] Label:1
features:[29218 29235 29207 29224] Label:1
features:[29224 29244 29223 29234] Label:1
features:[29234 29247 29222 29240] Label:1
features:[29240 29264 29240 29263] Label:1
features:[29263 29267 29234 29237] Label:1
features:[29237 29270 29232 29267] Label:0
features:[29267 29270 29252 29253] Label:2
And I got the following error when running it:
"ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]".
Can anyone advise on how to fix it?
Traceback (most recent call last):
File "ML.py", line 145, in <module>
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 851, in fit
initial_epoch=initial_epoch)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_generator.py", line 191, in model_iteration
batch_outs = batch_function(*batch_data)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1175, in train_on_batch
x, y, sample_weight=sample_weight, class_weight=class_weight)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2289, in _standardize_user_data
self._set_inputs(cast_inputs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/checkpointable/base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2529, in _set_inputs
outputs = self.call(inputs, training=training)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 233, in call
inputs, training=training, mask=mask)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 254, in _call_and_compute_mask
layer._maybe_build(x)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1591, in _maybe_build
self.input_spec, inputs, self.name)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py", line 139, in assert_input_compatibility
str(x.shape.as_list()))
ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]
python tensorflow
I am new to Tensorflow and trying to work on it using the sample code below:
def build_model():
model = keras.Sequential([
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(10, activation=tf.nn.relu),
layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)
model.compile(loss='mean_squared_error',
optimizer=optimizer,
metrics=['mean_absolute_error', 'mean_squared_error'])
return model
model = build_model()
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
The training_dataset is as below with 179 rows:
features:[29225 29259 29210 29220] Label:2
features:[29220 29236 29201 29234] Label:1
features:[29234 29241 29211 29221] Label:2
features:[29221 29224 29185 29185] Label:2
features:[29185 29199 29181 29191] Label:2
features:[29191 29195 29171 29195] Label:1
features:[29195 29228 29189 29225] Label:1
features:[29225 29236 29196 29199] Label:2
features:[29199 29222 29197 29218] Label:1
features:[29218 29235 29207 29224] Label:1
features:[29224 29244 29223 29234] Label:1
features:[29234 29247 29222 29240] Label:1
features:[29240 29264 29240 29263] Label:1
features:[29263 29267 29234 29237] Label:1
features:[29237 29270 29232 29267] Label:0
features:[29267 29270 29252 29253] Label:2
And I got the following error when running it:
"ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]".
Can anyone advise on how to fix it?
Traceback (most recent call last):
File "ML.py", line 145, in <module>
model.fit(training_dataset, epochs=5, steps_per_epoch=179)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 851, in fit
initial_epoch=initial_epoch)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_generator.py", line 191, in model_iteration
batch_outs = batch_function(*batch_data)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 1175, in train_on_batch
x, y, sample_weight=sample_weight, class_weight=class_weight)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2289, in _standardize_user_data
self._set_inputs(cast_inputs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/training/checkpointable/base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 2529, in _set_inputs
outputs = self.call(inputs, training=training)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 233, in call
inputs, training=training, mask=mask)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/sequential.py", line 254, in _call_and_compute_mask
layer._maybe_build(x)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1591, in _maybe_build
self.input_spec, inputs, self.name)
File "/home/sandbox/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py", line 139, in assert_input_compatibility
str(x.shape.as_list()))
ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=1. Full shape received: [None]
python tensorflow
python tensorflow
edited Mar 28 at 4:27
jkdev
5,8836 gold badges39 silver badges69 bronze badges
5,8836 gold badges39 silver badges69 bronze badges
asked Mar 28 at 3:54
LoKLoK
194 bronze badges
194 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
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/4.0/"u003ecc by-sa 4.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%2f55389913%2fvalueerror-input-0-of-layer-dense-is-incompatible-with-the-layer-expected-mi%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
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%2f55389913%2fvalueerror-input-0-of-layer-dense-is-incompatible-with-the-layer-expected-mi%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