卷积神经网络训练图片报错未定义和没有足够的值解包

def get_batch(data,label,batch_size):

for start_index in range(0,len(data)-batch_size+1,batch_size):
    slice_index = slice(start_index,start_index+batch_size)
    yield data[slice_index],label[slice_index]

with tf.Session() as sess:

    if train:
        print("训练模式")
        sess.run(tf.global_variables_initializer())

        batch_size=80
        for step in range(600):
                for train_data_batch,train_label_batch in get_batch(x_train,y_train,batch_size):
                        train_feed_dict={datas_placeholder:train_data_batch,labels_placeholder:train_label_batch,dropout_placeholdr:0.65}

                _, mean_loss_val = sess.run([optimizer, mean_loss], feed_dict=train_feed_dict)

这段代码的报错是mean_loss_val中的train_feed_dict未定义

然后我尝试改动这个for内的代码

def get_batch(data,label,batch_size):

for start_index in range(0,len(data)-batch_size+1,batch_size):
    slice_index = slice(start_index,start_index+batch_size)
    yield data[slice_index],label[slice_index]

with tf.Session() as sess:

    if train:
            print("训练模式")
            sess.run(tf.global_variables_initializer())

            batch_size=80
            for step in range(600):
                train_data_batch,train_label_batch =  get_batch(x_train,y_train,batch_size)
                train_feed_dict={datas_placeholder:train_data_batch,labels_placeholder:train_label_batch,dropout_placeholdr:0.65}
                _, mean_loss_val = sess.run([optimizer, mean_loss], feed_dict=train_feed_dict)

这段代码报错ValueError: not enough values to unpack (expected 2, got 0

1个回答

weixin_44842869
pastxx 不是同一个问题啊
12 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问