model.summary() in Tensorflow like Keras
Use Slim
Example:
import numpy as np from tensorflow.python.layers import base import tensorflow as tf import tensorflow.contrib.slim as slim x = np.zeros((1,4,4,3)) x_tf = tf.convert_to_tensor(x, np.float32) z_tf = tf.layers.conv2d(x_tf, filters=32, kernel_size=(3,3)) def model_summary(): model_vars = tf.trainable_variables() slim.model_analyzer.analyze_vars(model_vars, print_info=True) model_summary()
Output:
--------- Variables: name (type shape) [size] --------- conv2d/kernel:0 (float32_ref 3x3x3x32) [864, bytes: 3456] conv2d/bias:0 (float32_ref 32) [32, bytes: 128] Total size of variables: 896 Total bytes of variables: 3584
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Use Slim to overview model in Tensorflow like model.summary() in Keras - Python技术站