Chcę zobaczyć zmienne, które są zapisywane w punkcie kontrolnym tensorflow wraz z ich wartościami. Jak znaleźć nazwy zmiennych zapisane w punkcie kontrolnym tensorflow?Jak znaleźć nazwy zmiennych zapisane w punkcie kontrolnym tensorflow?
Edycja:
kiedyś tf.train.NewCheckpointReader
co wynika here. Ale nie jest to podane w dokumentacji tensorflow. Czy jest jakiś inny sposób?
`
import tensorflow as tf
v0 = tf.Variable([[1, 2, 3], [4, 5, 6]], dtype=tf.float32, name="v0")
v1 = tf.Variable([[[1], [2]], [[3], [4]], [[5], [6]]], dtype=tf.float32,
name="v1")
init_all_op = tf.initialize_all_variables()
save = tf.train.Saver({"v0": v0, "v1": v1})
checkpoint_path = os.path.join(model_dir, "model.ckpt")
with tf.Session() as sess:
sess.run(init_all_op)
# Saves a checkpoint.
save.save(sess, checkpoint_path)
# Creates a reader.
reader = tf.train.NewCheckpointReader(checkpoint_path)
print('reder:\n', reader)
# Verifies that the tensors exist.
print('is exist v0?', reader.has_tensor("v0"))
print('is exist v1?', reader.has_tensor("v1"))
# Verifies that debug string contains the right strings.
debug_string = reader.debug_string()
print('\n All Variables: \n', debug_string)
# Verifies get_variable_to_shape_map() returns the correct information.
var_map = reader.get_variable_to_shape_map()
print('\n All Variables information :\n', var_map)
# Verifies get_tensor() returns the tensor value.
v0_tensor = reader.get_tensor("v0")
v1_tensor = reader.get_tensor("v1")
print('\n returns the v0 tensor value:\n', v0_tensor)
print('\n returns the v1 tensor value:\n', v1_tensor)
`
Widziałem, że przyjąłeś odpowiedź. Zatem, jaki jest kod, który napisałeś, aby uruchomić funkcję 'print_tensors_in_checkpoint_file?' Próbowałem użyć tego, ale za każdym razem, gdy robię 'tf.python.tools.inspect_checkpoint.print_tensors_in_checkpoint_file' python mówi, że moduł' tensorflow.python' nie ma atrybut "narzędzia". Myślę, że byłoby niezmiernie pomocne, gdybyś przedstawił mały przykładowy skrypt, jak uruchomić tę funkcję (ponieważ ten plik również nie dostarcza przykładu), zwłaszcza, że zaakceptowałeś odpowiedź, więc zakładam, że coś zadziałało. – Pinocchio