没啥可说的,直接上脚本
import tensorflow as tf
meta_graph_path = '/path-to-your-.meta-file'
load_mod = tf.train.import_meta_graph(meta_graph_path)
total_parameters = 0
for variable in tf.trainable_variables():
# shape is an array of tf.Dimension
shape = variable.get_shape()
print(shape)
print(len(shape))
variable_parameters = 1
for dim in shape:
print(dim)
variable_parameters *= dim.value
print(variable_parameters)
total_parameters += variable_parameters
print('The total number of parameters are: ', total_parameters)