FootMark.run 2017-11-25 02:15 采纳率: 0%
浏览 1840
已结题

tensorflow debug 调试错误

-*- coding: utf-8 -*-

"""
Created on Sat Oct 28 15:40:51 2017

@author: Administrator
"""

import tensorflow as tf
from tensorflow.python import debug as tf_debug

'''载入数据'''

from aamodule import input_data
mnist = input_data.read_data_sets('d://MNIST',one_hot=True)

'''构建回归模型'''

#定义回归模型
x = tf.placeholder(tf.float32,[None,784])
y = tf.placeholder(tf.float32,[None,10])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
y_ = tf.matmul(x,W) + b #预测值

#定义损失函数和优化器

cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=y_,labels=y)
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)

'''训练模型'''

sess = tf.InteractiveSession()

sess.run(tf.global_variables_initializer())

sess = tf_debug.LocalCLIDebugWrapperSession(sess,ui_type='readline')
#sess.add_tensor_filter("has_inf_or_nan", tf_debug.has_inf_or_nan)

#Train
for i in range(1000):
batch_xs,batch_ys = mnist.train.next_batch(100)
sess.run(train_step,feed_dict={x:batch_xs,y:batch_ys})

#评估训练好的模型
correct_prediction = tf.equal(tf.argmax(y_,1),tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction,tf.float32))

#计算模型在测试集上的准确率
print(sess.run(accuracy,feed_dict={x:mnist.test.images,y:mnist.test.labels}))

加入sess = tf_debug.LocalCLIDebugWrapperSession(sess,ui_type='readline')后就运行不了了,ValueError: Exhausted all fallback ui_types.


  • 写回答

1条回答 默认 最新

  • 小小逐月者 2018-05-28 13:41
    关注

    首先安装pyreadline,目的是让tfdbg可以在cmd中正确显示
    pip install pyreadline
    保留参数为 **ui_type='readline' **

    这样在就可以在cmd中正常使用了

    评论

报告相同问题?

悬赏问题

  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备