简体   繁体   English

tf.keras 中意外的权重数 Model

[英]Unexpected Number of Weights in tf.keras Sequential Model

I have a question about the predictive power of each feature so I need a way to evaluate how strong each feature is in the final model. My feature_layer contains two indicator_column s wrapped around categorical_column_with_vocabulary_list s for categorical data, an indicator_column wrapped around a cross between two bucketized numerical columns for latitude/longitude data, and five numeric columns.我对每个特征的预测能力有疑问,所以我需要一种方法来评估每个特征在最终 model 中的强度。我的feature_layer包含两个indicator_column环绕categorical_column_with_vocabulary_list用于分类数据,一个indicator_column环绕两个之间的交叉纬度/经度数据的桶化数字列和五个数字列。

I would expect the finished model to have 15 weights: 2 for the latitude and longitude, 5 for the numeric columns, and 5 and 3 for each of the categorical columns using one-hot encoding.我希望完成的 model 有 15 个权重:2 个用于纬度和经度,5 个用于数字列,5 个和 3 个用于使用单热编码的每个分类列。 However, len(model.get_weights())[0] returns 513. I suspect the latitude and longitude have many more weights since a cross between two bucketized columns ends up being a sparse categorical feature with a high enough resolution.但是, len(model.get_weights())[0]返回 513。我怀疑纬度和经度有更多的权重,因为两个分桶列之间的交叉最终成为具有足够高分辨率的稀疏分类特征。 However, assuming this is true, I still don't know how to interpret the weights returned by model.get_weights()[0] .但是,假设这是真的,我仍然不知道如何解释model.get_weights()[0]返回的权重。

I found out that the answer has to do with the hash_bucket_size argument in the crossed_column .我发现答案与 crossed_column 中的hash_bucket_size参数crossed_column Each of those hashes gets a weight of its own in the final model. The 513 weights were a result of the 13 weights from every other feature and the 500 hashes for the crossed latitude/longitude.这些哈希中的每一个在最终的 model 中都有自己的权重。513 个权重是来自每个其他特征的 13 个权重和交叉纬度/经度的 500 个哈希的结果。

In terms of interpreting the weights, I am under the assumption that the weights of the model remain in the order that I added features to the feature_layer .在解释权重方面,我假设 model 的权重保持在我向feature_layer添加特征的顺序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM