gpt4 book ai didi

python - TensorFlow - Tflearning 错误 feed_dict

转载 作者:太空宇宙 更新时间:2023-11-04 07:17:14 24 4
gpt4 key购买 nike

我正在研究 python 中的分类问题。事实上,我在 TensorFlow 方面还不是很好。所以我很久以来就有同样的问题,我不知道如何解决。我希望你能帮助我:)

这是我的数据:

X:8000 张图片:32*32px 和 3 种颜色 (rgb),所以我加载一个矩阵 X.shape = (8000,32,32,3)

Y:4 类(1、2、3 和 4):Y.shape = (8000,1)

这是我的代码:

network = input_data(shape=[None, 32, 32, 3], name='iput')                   
# Step 1: Convolution
network = conv_2d(network, 32, 3, activation='relu')
# Step 2: Max pooling
network = max_pool_2d(network, 2)
# Step 3: Convolution again
network = conv_2d(network, 64, 3, activation='relu')
# Step 4: Convolution yet again
network = conv_2d(network, 64, 3, activation='relu')
# Step 5: Max pooling again
network = max_pool_2d(network, 2)
# Step 6: Fully-connected 512 node neural network
network = fully_connected(network, 512, activation='relu')
# Step 7: Dropout - throw away some data randomly during training to prevent over-fitting
network = dropout(network, 0.5)
# Step 8: Fully-connected neural network with 4 outputs
network = fully_connected(network, 4, activation='softmax')
# Tell tflearn how we want to train the network
network = regression(network, optimizer='adam',
loss='categorical_crossentropy',
learning_rate=0.001)
model = tflearn.DNN(network)
model.fit(X, Y)

这是我的错误

Traceback (most recent call last):

File "", line 3, in

model.fit(X, Y)

File "/home/side/anaconda3/lib/python3.5/site-packages/tflearn/models/dnn.py",

line 157, in fit

self.targets)

File "/home/side/anaconda3/lib/python3.5/site-packages/tflearn/utils.py", line 267, in feed_dict_builder feed_dict[net_inputs[i]] = x IndexError: list index out of range

我还尝试将 X 作为 (8000,3072) 矩阵传递Y 为 (8000,4) 矩阵,例如:

[0 0 1 0 <-- Y[0] = 3

0 1 0 0 <-- Y[1] = 2

...]

我重用了这段代码:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_cifar10.py , 用于对 cifar10 数据进行分类。

谢谢你的帮助,

西莉亚

最佳答案

另一种选择是添加:

tf.reset_default_graph()

作为代码的第一行

关于python - TensorFlow - Tflearning 错误 feed_dict,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38064449/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com