我按照这两篇文章来了解恢复已保存的模型,然后从中提取变量:
但现在我无法理解这些变量究竟意味着什么以及如何理解模型对学习过程中的特征给出的相对重要性?以下是我的代码中tf.train.list_variables
和tf.train.load_variables
(分别)的输出:
>> tf.train.list_variables('./dnn_fe_trial1/model.ckpt-1')
[('dnn/hiddenlayer_0/biases', [50]),
('dnn/hiddenlayer_0/biases/enlayer_0/biases/part_0/Adam', [50]),
('dnn/hiddenlayer_0/biases/enlayer_0/biases/part_0/Adam_1', [50]),
('dnn/hiddenlayer_0/weights', [61, 50]),
('dnn/hiddenlayer_0/weights/nlayer_0/weights/part_0/Adam', [61, 50]),
('dnn/hiddenlayer_0/weights/nlayer_0/weights/part_0/Adam_1', [61, 50]),
('dnn/input_from_feature_columns/brand_embedding/weights', [10000, 16]),
('dnn/input_from_feature_columns/brand_embedding/weights/mbedding/weights/part_0/Adam', [10000, 16]),
('dnn/input_from_feature_columns/brand_embedding/weights/mbedding/weights/part_0/Adam_1', [10000, 16]),
('dnn/input_from_feature_columns/city_embedding/weights', [12, 3]),
('dnn/input_from_feature_columns/city_embedding/weights/mbedding/weights/part_0/Adam', [12, 3]),
('dnn/input_from_feature_columns/city_embedding/weights/mbedding/weights/part_0/Adam_1', [12, 3]),
('dnn/input_from_feature_columns/dow_embedding/weights', [7, 3]),
('dnn/input_from_feature_columns/dow_embedding/weights/mbedding/weights/part_0/Adam', [7, 3]),
('dnn/input_from_feature_columns/dow_embedding/weights/mbedding/weights/part_0/Adam_1', [7, 3]),
('dnn/input_from_feature_columns/l_cat_embedding/weights', [11, 3]),
('dnn/input_from_feature_columns/l_cat_embedding/weights/mbedding/weights/part_0/Adam', [11, 3]),
('dnn/input_from_feature_columns/l_cat_embedding/weights/mbedding/weights/part_0/Adam_1', [11, 3]),
('dnn/input_from_feature_columns/product_id_embedding/weights', [10000, 16]),
('dnn/input_from_feature_columns/product_id_embedding/weights/mbedding/weights/part_0/Adam', [10000, 16]),
('dnn/input_from_feature_columns/product_id_embedding/weights/mbedding/weights/part_0/Adam_1', [10000, 16]),
('dnn/input_from_feature_columns/type_id_embedding/weights', [10000, 16]),
('dnn/input_from_feature_columns/type_id_embedding/weights/mbedding/weights/part_0/Adam', [10000, 16]),
('dnn/input_from_feature_columns/type_id_embedding/weights/mbedding/weights/part_0/Adam_1', [10000, 16]),
('dnn/logits/biases', [1]),
('dnn/logits/biases/nn/logits/biases/part_0/Adam', [1]),
('dnn/logits/biases/nn/logits/biases/part_0/Adam_1', [1]),
('dnn/logits/weights', [50, 1]),
('dnn/logits/weights/n/logits/weights/part_0/Adam', [50, 1]),
('dnn/logits/weights/n/logits/weights/part_0/Adam_1', [50, 1]),
('dnn/regression_head/dnn/learning_rate', []),
('dnn/regression_head/train_op/dnn/beta1_power', []),
('dnn/regression_head/train_op/dnn/beta2_power', []),
('global_step', [])]
>> tf.train.load_variable('./dnn_fe_trial1/model.ckpt-1','dnn/hiddenlayer_0/weights')
array([[ 0.14350541, 0.18532775, -0.03176343, ..., -0.07279533,
-0.08580479, -0.07619692],
[ 0.16894072, -0.10593006, 0.06088932, ..., -0.01411209,
-0.26995516, 0.15667924],
[-0.10020741, -0.03164399, -0.14427225, ..., -0.02787848,
-0.15646952, -0.1361219 ],
...,
[ 0.15014522, 0.15378515, -0.05414914, ..., -0.16788298,
-0.14711154, -0.226382 ],
[-0.16823539, 0.2009476 , -0.271177 , ..., -0.10694946,
-0.22870012, -0.13458726],
[-0.13175508, 0.15535942, -0.18468232, ..., -0.1362714 ,
-0.27476427, -0.21606216]], dtype=float32)