2016-03-04 38 views

回答

40

模型和层具有用于此目的的特殊方法:

model.count_params() 

此外,为了获得每一层的尺寸和参数的简短摘要,你可能会发现有用以下方法

model.summary() 
10
import keras.backend as K 

def size(model): # Compute number of params in a model (the actual number of floats) 
    return sum([np.prod(K.get_value(w).shape) for w in model.trainable_weights])