[英]How can I visualize the estimator Trained model in tensorflow?
I have created a model with 3 hidden layers and trained it with the specific data-set. 我创建了一个具有3个隐藏层的模型,并使用特定的数据集对其进行了训练。
How can I visualize the Model, with the neuron connections and weights at each iteration. 我如何可视化模型,以及每次迭代的神经元连接和权重。
Here is the snippet of the python code : 这是python代码的片段:
#<ALL IMPORT STATEMENTS>
MODEL_DIR = <model_name>
def make_estimator(model_dir):
config = run_config.RunConfig(model_dir=model_dir)
feat_cols = [tf.feature_column.numeric_column("x", shape=<number_of_feat_cols>)]
return estimator.DNNClassifier(config=config, hidden_units=[<>,<>,<>],feature_columns=feat_cols,n_classes=2,optimizer=tf.train.GradientDescentOptimizer(learning_rate=0.001))
data = pd.read_csv(<csv_file>)
feat_data = data.drop('Type',axis=1)
feat_data_matrix = feat_data.as_matrix()
labels = data['Type']
labels_matrix = labels.as_matrix()
deep_model = make_estimator(MODEL_DIR)
input_fn = estimator.inputs.numpy_input_fn(x={'x':feat_data_matrix}, y=labels_matrix, shuffle=True, batch_size=10, num_epochs=1000)
tr_steps = <step_size>
deep_model.train(input_fn=input_fn,steps=tr_steps)
print ("Training Done")
In the code above, I have not created any tensorflow session, without it where can I implement the TensorBoard APIs for visualizing the model ? 在上面的代码中,我没有创建任何tensorflow会话,没有它,我在哪里可以实现用于可视化模型的TensorBoard API?
By using the Python API
simply call the method tf.summary.FileWriter
通过使用Python API
只需调用方法tf.summary.FileWriter
Then if you load the file written by the SummaryWriter into TensorBoard, the graph is shown. 然后,如果您将SummaryWriter写入的文件加载到TensorBoard中,则会显示该图。
You have to load the graph like this: 您必须像这样加载图形:
# Launch the graph.
current_session = tf.Session()
current_session.run(init)
# Create a summary writer, add the 'graph' to the event file.
writer = tf.summary.FileWriter(<some-directory>, current_session.graph)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.