1. 程式人生 > >Use Slim to overview model in Tensorflow like model.summary() in Keras

Use Slim to overview model in Tensorflow like model.summary() in Keras

convert num kernel code http style int tensor bytes

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

來源: https://stackoverflow.com/questions/46560313/is-there-an-easy-way-to-get-something-like-keras-model-summary-in-tensorflow

Use Slim to overview model in Tensorflow like model.summary() in Keras