ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4
I got an error,ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'.
I wrote codes,
# coding: utf-8
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[2, 4, 104])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 10, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Traceback says
Traceback (most recent call last):
File "cnn.py", line 16, in <module>
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/models/dnn.py", line 216, in fit
callbacks=callbacks)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 339, in fit
show_metric)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 818, in _train
feed_batch)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1128, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'
I rewrote into
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
trainLabel = np.array([[0,1],[0,1],[1,0]])
but same error happens.What is wrong in my codes?How should I fix this?
python tensorflow tflearn
add a comment |
I got an error,ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'.
I wrote codes,
# coding: utf-8
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[2, 4, 104])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 10, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Traceback says
Traceback (most recent call last):
File "cnn.py", line 16, in <module>
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/models/dnn.py", line 216, in fit
callbacks=callbacks)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 339, in fit
show_metric)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 818, in _train
feed_batch)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1128, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'
I rewrote into
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
trainLabel = np.array([[0,1],[0,1],[1,0]])
but same error happens.What is wrong in my codes?How should I fix this?
python tensorflow tflearn
what is 104 in shape?
– Geeocode
Nov 11 '18 at 14:47
@Geeocode 104 is this 104 ofnet = input_data(shape=[2, 4, 104])
– user10492592
Nov 11 '18 at 14:48
sure, but you have a trainDataSet shape(3,4)
– Geeocode
Nov 11 '18 at 14:52
You have to provide more information about what your expected output regarding trainlabel and what 104 stand for etc.
– Geeocode
Nov 11 '18 at 15:21
add a comment |
I got an error,ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'.
I wrote codes,
# coding: utf-8
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[2, 4, 104])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 10, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Traceback says
Traceback (most recent call last):
File "cnn.py", line 16, in <module>
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/models/dnn.py", line 216, in fit
callbacks=callbacks)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 339, in fit
show_metric)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 818, in _train
feed_batch)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1128, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'
I rewrote into
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
trainLabel = np.array([[0,1],[0,1],[1,0]])
but same error happens.What is wrong in my codes?How should I fix this?
python tensorflow tflearn
I got an error,ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'.
I wrote codes,
# coding: utf-8
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[2, 4, 104])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 10, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Traceback says
Traceback (most recent call last):
File "cnn.py", line 16, in <module>
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/models/dnn.py", line 216, in fit
callbacks=callbacks)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 339, in fit
show_metric)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tflearn/helpers/trainer.py", line 818, in _train
feed_batch)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/Users/xxx/anaconda/xxx/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1128, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (2, 4) for Tensor u'InputData/X:0', which has shape '(?, 2, 4, 104)'
I rewrote into
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
trainLabel = np.array([[0,1],[0,1],[1,0]])
but same error happens.What is wrong in my codes?How should I fix this?
python tensorflow tflearn
python tensorflow tflearn
asked Nov 11 '18 at 14:42
user10492592user10492592
234
234
what is 104 in shape?
– Geeocode
Nov 11 '18 at 14:47
@Geeocode 104 is this 104 ofnet = input_data(shape=[2, 4, 104])
– user10492592
Nov 11 '18 at 14:48
sure, but you have a trainDataSet shape(3,4)
– Geeocode
Nov 11 '18 at 14:52
You have to provide more information about what your expected output regarding trainlabel and what 104 stand for etc.
– Geeocode
Nov 11 '18 at 15:21
add a comment |
what is 104 in shape?
– Geeocode
Nov 11 '18 at 14:47
@Geeocode 104 is this 104 ofnet = input_data(shape=[2, 4, 104])
– user10492592
Nov 11 '18 at 14:48
sure, but you have a trainDataSet shape(3,4)
– Geeocode
Nov 11 '18 at 14:52
You have to provide more information about what your expected output regarding trainlabel and what 104 stand for etc.
– Geeocode
Nov 11 '18 at 15:21
what is 104 in shape?
– Geeocode
Nov 11 '18 at 14:47
what is 104 in shape?
– Geeocode
Nov 11 '18 at 14:47
@Geeocode 104 is this 104 of
net = input_data(shape=[2, 4, 104])
– user10492592
Nov 11 '18 at 14:48
@Geeocode 104 is this 104 of
net = input_data(shape=[2, 4, 104])
– user10492592
Nov 11 '18 at 14:48
sure, but you have a trainDataSet shape(3,4)
– Geeocode
Nov 11 '18 at 14:52
sure, but you have a trainDataSet shape(3,4)
– Geeocode
Nov 11 '18 at 14:52
You have to provide more information about what your expected output regarding trainlabel and what 104 stand for etc.
– Geeocode
Nov 11 '18 at 15:21
You have to provide more information about what your expected output regarding trainlabel and what 104 stand for etc.
– Geeocode
Nov 11 '18 at 15:21
add a comment |
1 Answer
1
active
oldest
votes
Citing from the Tensorflow documentation:
tflearn.layers.conv.conv_2d
Input:
4-D Tensor [batch, height, width, in_channels].
From other Tensorflow documentation:
tf.nn.conv2d
Computes a 2-D convolution given 4-D input and filter tensors.
Given an input tensor of shape [batch, in_height, in_width,
in_channels] and a filter / kernel tensor of shape [filter_height,
filter_width, in_channels, out_channels], this op performs the
following:
Your dataset, label and input shape aren't aligning i.e. doesn't fit to each other.
Currently your trainDataSet
has the shape of (3,4):
import numpy as np
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
print(trainDataSet.shape)
Out:
(3, 4)
But you defined the input shape as:
net = input_data(shape=[2, 4, 104])
Ambiguous what you really want to achieve, but if you wanted to see a simple working example, that your code should have been seen as follows:
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[3, 4, 1])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
]
]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Out:
---------------------------------
Run id: NHHJV7
Log directory: /tmp/tflearn_logs/
INFO:tensorflow:Summary name Accuracy/ (raw) is illegal; using Accuracy/__raw_ instead.
---------------------------------
Training samples: 2
Validation samples: 1
--
Training Step: 1 | time: 1.160s
| Adam | epoch: 001 | loss: 0.00000 - acc: 0.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 2 | total loss: 0.62966 | time: 1.008s
| Adam | epoch: 002 | loss: 0.62966 - acc: 0.0000 | val_loss: 10.76885 - val_acc: 0.0000 -- iter: 2/2
.
.
.
Training Step: 99 | total loss: 0.00000 | time: 1.013s
| Adam | epoch: 099 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 100 | total loss: 0.00000 | time: 1.011s
| Adam | epoch: 100 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
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%2f53249807%2fvalueerror-cannot-feed-value-of-shape-2-4-for-tensor-uinputdata-x0-which%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
Citing from the Tensorflow documentation:
tflearn.layers.conv.conv_2d
Input:
4-D Tensor [batch, height, width, in_channels].
From other Tensorflow documentation:
tf.nn.conv2d
Computes a 2-D convolution given 4-D input and filter tensors.
Given an input tensor of shape [batch, in_height, in_width,
in_channels] and a filter / kernel tensor of shape [filter_height,
filter_width, in_channels, out_channels], this op performs the
following:
Your dataset, label and input shape aren't aligning i.e. doesn't fit to each other.
Currently your trainDataSet
has the shape of (3,4):
import numpy as np
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
print(trainDataSet.shape)
Out:
(3, 4)
But you defined the input shape as:
net = input_data(shape=[2, 4, 104])
Ambiguous what you really want to achieve, but if you wanted to see a simple working example, that your code should have been seen as follows:
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[3, 4, 1])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
]
]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Out:
---------------------------------
Run id: NHHJV7
Log directory: /tmp/tflearn_logs/
INFO:tensorflow:Summary name Accuracy/ (raw) is illegal; using Accuracy/__raw_ instead.
---------------------------------
Training samples: 2
Validation samples: 1
--
Training Step: 1 | time: 1.160s
| Adam | epoch: 001 | loss: 0.00000 - acc: 0.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 2 | total loss: 0.62966 | time: 1.008s
| Adam | epoch: 002 | loss: 0.62966 - acc: 0.0000 | val_loss: 10.76885 - val_acc: 0.0000 -- iter: 2/2
.
.
.
Training Step: 99 | total loss: 0.00000 | time: 1.013s
| Adam | epoch: 099 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 100 | total loss: 0.00000 | time: 1.011s
| Adam | epoch: 100 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
add a comment |
Citing from the Tensorflow documentation:
tflearn.layers.conv.conv_2d
Input:
4-D Tensor [batch, height, width, in_channels].
From other Tensorflow documentation:
tf.nn.conv2d
Computes a 2-D convolution given 4-D input and filter tensors.
Given an input tensor of shape [batch, in_height, in_width,
in_channels] and a filter / kernel tensor of shape [filter_height,
filter_width, in_channels, out_channels], this op performs the
following:
Your dataset, label and input shape aren't aligning i.e. doesn't fit to each other.
Currently your trainDataSet
has the shape of (3,4):
import numpy as np
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
print(trainDataSet.shape)
Out:
(3, 4)
But you defined the input shape as:
net = input_data(shape=[2, 4, 104])
Ambiguous what you really want to achieve, but if you wanted to see a simple working example, that your code should have been seen as follows:
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[3, 4, 1])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
]
]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Out:
---------------------------------
Run id: NHHJV7
Log directory: /tmp/tflearn_logs/
INFO:tensorflow:Summary name Accuracy/ (raw) is illegal; using Accuracy/__raw_ instead.
---------------------------------
Training samples: 2
Validation samples: 1
--
Training Step: 1 | time: 1.160s
| Adam | epoch: 001 | loss: 0.00000 - acc: 0.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 2 | total loss: 0.62966 | time: 1.008s
| Adam | epoch: 002 | loss: 0.62966 - acc: 0.0000 | val_loss: 10.76885 - val_acc: 0.0000 -- iter: 2/2
.
.
.
Training Step: 99 | total loss: 0.00000 | time: 1.013s
| Adam | epoch: 099 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 100 | total loss: 0.00000 | time: 1.011s
| Adam | epoch: 100 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
add a comment |
Citing from the Tensorflow documentation:
tflearn.layers.conv.conv_2d
Input:
4-D Tensor [batch, height, width, in_channels].
From other Tensorflow documentation:
tf.nn.conv2d
Computes a 2-D convolution given 4-D input and filter tensors.
Given an input tensor of shape [batch, in_height, in_width,
in_channels] and a filter / kernel tensor of shape [filter_height,
filter_width, in_channels, out_channels], this op performs the
following:
Your dataset, label and input shape aren't aligning i.e. doesn't fit to each other.
Currently your trainDataSet
has the shape of (3,4):
import numpy as np
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
print(trainDataSet.shape)
Out:
(3, 4)
But you defined the input shape as:
net = input_data(shape=[2, 4, 104])
Ambiguous what you really want to achieve, but if you wanted to see a simple working example, that your code should have been seen as follows:
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[3, 4, 1])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
]
]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Out:
---------------------------------
Run id: NHHJV7
Log directory: /tmp/tflearn_logs/
INFO:tensorflow:Summary name Accuracy/ (raw) is illegal; using Accuracy/__raw_ instead.
---------------------------------
Training samples: 2
Validation samples: 1
--
Training Step: 1 | time: 1.160s
| Adam | epoch: 001 | loss: 0.00000 - acc: 0.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 2 | total loss: 0.62966 | time: 1.008s
| Adam | epoch: 002 | loss: 0.62966 - acc: 0.0000 | val_loss: 10.76885 - val_acc: 0.0000 -- iter: 2/2
.
.
.
Training Step: 99 | total loss: 0.00000 | time: 1.013s
| Adam | epoch: 099 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 100 | total loss: 0.00000 | time: 1.011s
| Adam | epoch: 100 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Citing from the Tensorflow documentation:
tflearn.layers.conv.conv_2d
Input:
4-D Tensor [batch, height, width, in_channels].
From other Tensorflow documentation:
tf.nn.conv2d
Computes a 2-D convolution given 4-D input and filter tensors.
Given an input tensor of shape [batch, in_height, in_width,
in_channels] and a filter / kernel tensor of shape [filter_height,
filter_width, in_channels, out_channels], this op performs the
following:
Your dataset, label and input shape aren't aligning i.e. doesn't fit to each other.
Currently your trainDataSet
has the shape of (3,4):
import numpy as np
trainDataSet = np.array([[0.25,0.25,1,1],[0,0,1,1],[0.25,0.25,1,1]])
print(trainDataSet.shape)
Out:
(3, 4)
But you defined the input shape as:
net = input_data(shape=[2, 4, 104])
Ambiguous what you really want to achieve, but if you wanted to see a simple working example, that your code should have been seen as follows:
import tensorflow as tf
import tflearn
from tflearn.layers.core import input_data,dropout,fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import pandas as pd
import numpy as np
from sklearn import metrics
tf.reset_default_graph()
net = input_data(shape=[3, 4, 1])
net = conv_2d(net, 4, 16, activation='relu')
net = max_pool_2d(net, 1)
net = tflearn.activations.relu(net)
net = dropout(net, 0.5)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', learning_rate=0.5, loss='categorical_crossentropy')
model = tflearn.DNN(net)
trainDataSet = [
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
],
[
[[0.25], [0.25], [1], [1]],
[[0], [0], [1], [1]],
[[0.25], [0.25], [1], [1]]
]
]
trainLabel = [[0,1],[0,1],[1,0]]
model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
Out:
---------------------------------
Run id: NHHJV7
Log directory: /tmp/tflearn_logs/
INFO:tensorflow:Summary name Accuracy/ (raw) is illegal; using Accuracy/__raw_ instead.
---------------------------------
Training samples: 2
Validation samples: 1
--
Training Step: 1 | time: 1.160s
| Adam | epoch: 001 | loss: 0.00000 - acc: 0.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 2 | total loss: 0.62966 | time: 1.008s
| Adam | epoch: 002 | loss: 0.62966 - acc: 0.0000 | val_loss: 10.76885 - val_acc: 0.0000 -- iter: 2/2
.
.
.
Training Step: 99 | total loss: 0.00000 | time: 1.013s
| Adam | epoch: 099 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
Training Step: 100 | total loss: 0.00000 | time: 1.011s
| Adam | epoch: 100 | loss: 0.00000 - acc: 1.0000 | val_loss: 23.02585 - val_acc: 0.0000 -- iter: 2/2
--
edited Nov 11 '18 at 16:14
answered Nov 11 '18 at 15:01
GeeocodeGeeocode
2,3061820
2,3061820
add a comment |
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%2f53249807%2fvalueerror-cannot-feed-value-of-shape-2-4-for-tensor-uinputdata-x0-which%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
what is 104 in shape?
– Geeocode
Nov 11 '18 at 14:47
@Geeocode 104 is this 104 of
net = input_data(shape=[2, 4, 104])
– user10492592
Nov 11 '18 at 14:48
sure, but you have a trainDataSet shape(3,4)
– Geeocode
Nov 11 '18 at 14:52
You have to provide more information about what your expected output regarding trainlabel and what 104 stand for etc.
– Geeocode
Nov 11 '18 at 15:21