我想使用来自tensorboard的调试器插件。我按照以下步骤操作:
关于潜在问题或至少如何获得更多调试信息的任何想法?
来自此处的视频:https://www.youtube.com/watch?v=XcHWLsVmHvk
import numpy as np
import tensorflow as tf
from tensorflow.python import debug as tf_debug
k_true = [[1, -1], [3, -3], [2, -2]]
b_true = [-5, 5]
num_examples = 128
with tf.Session() as sess:
x = tf.placeholder(tf.float32, shape=[None, 3], name="x")
y = tf.placeholder(tf.float32, shape=[None, 2], name="y")
dense_layer = tf.keras.layers.Dense(2, use_bias=True)
y_hat = dense_layer(x)
loss = tf.reduce_mean(tf.keras.losses.mean_squared_error(y, y_hat), name="loss")
train_op = tf.train.GradientDescentOptimizer(0.05).minimize(loss)
sess.run(tf.global_variables_initializer())
sess = tf_debug.TensorBoardDebugWrapperSession(tf.Session(),
grpc_debug_server_addresses=['localhost:6064'],
send_traceback_and_source_code=False,
log_usage=True,
)
for i in range(50):
xs = np.random.randn(num_examples, 3)
ys = np.matmul(xs, k_true) + b_true
loss_val, _ = sess.run([loss, train_op], feed_dict={x: xs, y: ys})
print("Iteration %d: loss = %g" % (i, loss_val))
print("=== Completed")
$ python3 example_debug.py
2019-05-23 12:56:58.809390: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-05-23 12:56:58.832630: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2712000000 Hz
2019-05-23 12:56:58.833357: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x5642f1088ec0 executing computations on platform Host. Devices:
2019-05-23 12:56:58.833373: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): <undefined>, <undefined>
WARNING:tensorflow:From /home/cgebbe/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/cgebbe/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
^C
无需附加调试器,程序即可轻松运行。 tfdbg也可以。