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中正常使用了

    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度