溫馨提示×

tensorflow模型參數怎么查看

小億
242
2024-01-09 15:24:31
欄目: 深度學習

在TensorFlow中,可以使用model.summary()方法來查看模型的參數。這個方法會打印出模型的結構以及每一層的參數數量。示例如下:

import tensorflow as tf

# 創建模型
model = tf.keras.Sequential([
    tf.keras.layers.Dense(64, activation='relu', input_shape=(784,)),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(10, activation='softmax')
])

# 打印模型參數
model.summary()

運行上述代碼,會輸出模型的結構以及每一層的參數數量。例如:

Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 64)                50240     
_________________________________________________________________
dense_1 (Dense)              (None, 64)                4160      
_________________________________________________________________
dense_2 (Dense)              (None, 10)                650       
=================================================================
Total params: 55,050
Trainable params: 55,050
Non-trainable params: 0
_________________________________________________________________

在上述輸出中,每一層的參數數量都會顯示在Param #這一列中。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女