pastxx 2019-07-30 09:56 采纳率: 50%
浏览 460

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

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条回答

  • dabocaiqq 2019-07-30 10:12
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3