Reintroduce optional scaling of the teacher signal.

This commit is contained in:
Tomasz Sobczyk
2020-11-30 20:32:53 +01:00
committed by nodchip
parent 01ae7b1e2c
commit de675e3503
2 changed files with 69 additions and 1 deletions

View File

@@ -220,6 +220,25 @@ namespace Learner
return loss_;
}
template <typename ValueT>
static auto& scale_score_(ValueT&& v_)
{
using namespace Learner::Autograd::UnivariateStatic;
// Normalize to [0.0, 1.0].
static thread_local auto normalized_ =
(std::forward<ValueT>(v_) - ConstantRef<double>(src_score_min_value))
/ (ConstantRef<double>(src_score_max_value) - ConstantRef<double>(src_score_min_value));
// Scale to [dest_score_min_value, dest_score_max_value].
static thread_local auto scaled_ =
normalized_
* (ConstantRef<double>(dest_score_max_value) - ConstantRef<double>(dest_score_min_value))
+ ConstantRef<double>(dest_score_min_value);
return scaled_;
}
template <typename ValueT>
static auto& expected_perf_(ValueT&& v_)
{
@@ -249,7 +268,7 @@ namespace Learner
*/
static thread_local auto q_ = expected_perf_(VariableParameter<double, 0>{});
static thread_local auto p_ = expected_perf_(ConstantParameter<double, 1>{});
static thread_local auto p_ = expected_perf_(scale_score_(ConstantParameter<double, 1>{}));
static thread_local auto t_ = (ConstantParameter<double, 2>{} + 1.0) * 0.5;
static thread_local auto lambda_ = ConstantParameter<double, 3>{};
static thread_local auto loss_ = cross_entropy_(q_, p_, t_, lambda_);