tensorflow1.0 一些操作
打印所有节点:
[n.name for n in tf.get_default_graph().as_graph_def().node]
save parameter to dict:
model_save = {}
variables = tf.get_collection('variables')
for var in variables:
name = var.name
name = name.split(":")[0]
layer, parameter = name.split("/")
if layer not in model_save.keys():
model_save[layer] = dict()
model_save[layer][parameter] = var.eval()
view graph on tensorboard:
writer = tf.summary.FileWriter("logs/", sess.graph)
start tensorboard
tensorboard --logdir logs --host 0.0.0.0 --port 6006