简体   繁体   English

权重_列值归一化

[英]Weight_column value normalization

I use a TensorFlow canned estimator to predict game actions from situations favourizing best scores (there are no "good" or "bad" answers but an answer ib better than another depending the situation). 我使用TensorFlow固定估计器从有利于最高分的情况(没有“好”或“坏”的答案,但是根据情况而定的另一个答案)预测游戏动作。 This reality is represented by scores for each situation / action sample.Scores are included in train_data and used as weight and passed as weight column in the estimator. 每种情况/动作样本的得分都代表了这个现实。得分包含在train_data中,用作权重,并作为估计器中的权重列传递。

1 ) I tried without weight column : the model fits about 70 % with good answers. 1)我尝试了没有重量列的情况:该模型适合70%且有良好答案。 The model is correct for main examples but is not optimal for marginal examples (about 20 % remaining...) 该模型适用于主要示例,但不适用于边缘示例(剩余约20%...)

2 ) I tried with weight = exp(-score). 2)我尝试了weight = exp(-score)。 Model fits about 45 %, is better dealing with marginal examples but have a very poor accuracy with main examples. 模型适合约45%,可以更好地处理边际示例,但主要示例的准确性非常差。

I think there is a problem with my weights scale [0.0001 - 5003.98] with 0.0001 for the best result and 5003.98 for worth. 我认为我的体重秤[0.0001-5003.98]存在问题,最好的结果为0.0001,价值为5003.98。 What is the good way to regularize it ?? 使它正规化的好方法是什么?

I read the formula weight = (score - mean(score)) / std(score) could be a solution but doesn't seems work 我读过公式weight =(score-mean(score))/ std(score)可能是一个解决方案,但似乎不起作用

model = tf.estimator.LinearClassifier(feature_columns=feature_columns,
                                    optimizer=tf.train.AdamOptimizer(learning_rate=0.001, beta1= 0.9,beta2=0.99, epsilon = 1e-08,use_locking=False),
                                    weight_column=weights,
                                    n_classes=10,
                                    label_vocabulary=Action_vocab,
                                    model_dir='./Models/ActionPlayerModel20/',
                                    loss_reduction=tf.losses.Reduction.SUM_OVER_BATCH_SIZE,
                                    config=tf.estimator.RunConfig().replace(save_summary_steps=10))

weight = exp(-score)

Solved the weight problem by doing this (scaling): 通过执行以下操作解决了重量问题(缩放):

 scaledWeight = (weight-weightMin)/(weightMax-weightMin)

It did not completly resolve my problem (Better but not optimal accuracy). 它不能完全解决我的问题(更好但不是最佳精度)。 So, I tried both feature normalization and standardization : good accuracy with normalization but quick overfitting ; 因此,我尝试了特征归一化和标准化:归一化的精度很高,但过拟合很快; very good accuracy and slow overfitting with standardization. 非常好的准确性,并且标准化过慢。

Standardization code : 标准化代码:

    tf.feature_column.numeric_column("Round",dtype=tf.dtypes.float32, normalizer_fn=lambda x: (x - roundMean) / roundStd),

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

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