TensorFlowとtflearnを使い、ネットワークを構築しています。
ValueError: Cannot feed value of shape (9, 104) for Tensor u'InputData/X:0', which has shape '(?, 11, 104)'とエラーがでました。
Tracebackには、
Training samples: 9 Validation samples: 2 Traceback (most recent call last): File "cnn.py", line 167, 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 (9, 104) for Tensor u'InputData/X:0', which has shape '(?, 11, 104)'
とでました。
コードは
# 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_1d, max_pool_1d 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=[11, 104]) net = conv_1d(net, 4, 16, activation='relu') net = max_pool_1d(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) model.fit(trainDataSet, trainLabel, n_epoch=100, batch_size=32, validation_set=0.1, show_metric=True)
と書きました。
print(trainDataSet.shape)
とすると、(11, 104)とでて、
print(trainLabel.shape)
とすると、(11, 2)とでます。
なぜ、(9, 104)とエラー内容に表示されるのかわかりません。
どのように修正したらいいのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/13 06:07
2018/11/13 06:08
2018/11/13 06:08
2018/11/13 06:08
2018/11/13 06:08
2018/11/13 06:29
2018/11/13 13:38
2018/11/21 08:27
2018/11/21 10:58
2018/11/21 14:04