简体   繁体   English

如何在张量流中可视化估计量训练模型?

[英]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)

See here. 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将训练有素的Tensorflow模型加载到估算器中 - Loading trained Tensorflow model into estimator 如何保存训练有素的模型(Estimator)并将其加载回来用Tensorflow中的数据进行测试? - How to save a trained model (Estimator) and Load it back to test it with data in Tensorflow? 如何将在 tensorflow 2 中训练的模型转换为 tensorflow 1 冻结图 - How can I convert a model trained in tensorflow 2 to a tensorflow 1 frozen graph 如何访问和可视化预训练的 TensorFlow 2 模型中的权重? - How to access and visualize the weights in a pre-trained TensorFlow 2 model? Tensorflow:如何使用较早训练的估计量 - Tensorflow: how to use an estimator trained earlier 如何保存使用 tf.keras.estimator.model_to_estimator 创建的 tensorflow 估算器? - How do I save a tensorflow estimator created with tf.keras.estimator.model_to_estimator? 如何将 tensorflow 2.0 估计器 model 转换为 tensorflow lite? - How do i convert tensorflow 2.0 estimator model to tensorflow lite? 无法在Tensorflow估算器中训练Keras预训练模型 - Cannot Train Keras Pre-trained Model in Tensorflow Estimator 保存自定义tf.estimator训练模型的tensorflow服务 - Saving a custom tf.estimator trained model for tensorflow serving 我可以在model_fn,Estimator,Tensorflow中使用python进行循环吗? - Can I use python for loop in model_fn, Estimator, Tensorflow?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM