20
对于前馈网络(FFN),很容易计算参数的数量。给定一个CNN,LSTM等有一个快速的方法来找到keras模型中的参数数量?如何查找keras模型的参数数量?
对于前馈网络(FFN),很容易计算参数的数量。给定一个CNN,LSTM等有一个快速的方法来找到keras模型中的参数数量?如何查找keras模型的参数数量?
模型和层具有用于此目的的特殊方法:
model.count_params()
此外,为了获得每一层的尺寸和参数的简短摘要,你可能会发现有用以下方法
model.summary()
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])