Rename weightDecay to l2Lambda
Rbm::Params::weightDecay is now applied directly to the weights outside the momentum recursion (previous commit), exactly like the newly-added l1Lambda and matching pyRBM's l2_lambda -- same lambda*W gradient form, same decoupled-from-momentum treatment. The two are functionally the same mechanism in this codebase, so name it accordingly. Renamed the Params field, its JSON key, and the two GUI references in MainComponent.cpp that read/write it (the "weightDecayLabel" widget identifier and its JUCE-generated marker comment are left as-is -- cosmetic, not part of the actual API). Existing .prj files still have a "weightDecay" JSON key; fromJson() no longer reads it, so it's silently ignored on load. Harmless today since every current project has it set to 0.0 (confirmed: unchanged poet.elf output, unchanged test-suite results). Not migrating the .prj files themselves in this change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016K8Gu7Qejd11JbdiHZqYAs
This commit is contained in:
@@ -784,7 +784,7 @@ void MainComponent::labelTextChanged (Label* labelThatHasChanged)
|
|||||||
else if (labelThatHasChanged == weightDecayLabel)
|
else if (labelThatHasChanged == weightDecayLabel)
|
||||||
{
|
{
|
||||||
//[UserLabelCode_weightDecayLabel] -- add your label text handling code here..
|
//[UserLabelCode_weightDecayLabel] -- add your label text handling code here..
|
||||||
m_pLayer->params().weightDecay = labelThatHasChanged->getText().getFloatValue();
|
m_pLayer->params().l2Lambda = labelThatHasChanged->getText().getFloatValue();
|
||||||
//[/UserLabelCode_weightDecayLabel]
|
//[/UserLabelCode_weightDecayLabel]
|
||||||
}
|
}
|
||||||
else if (labelThatHasChanged == momentumLabel)
|
else if (labelThatHasChanged == momentumLabel)
|
||||||
@@ -947,7 +947,7 @@ void MainComponent::updateControls()
|
|||||||
rbmDoSampleVisibleToggleButton->setToggleState(m_pLayer->params().gibbsDoSampleVisible, dontSendNotification);
|
rbmDoSampleVisibleToggleButton->setToggleState(m_pLayer->params().gibbsDoSampleVisible, dontSendNotification);
|
||||||
rbmDoSampleHidden->setToggleState(m_pLayer->params().gibbsDoSampleHidden, dontSendNotification);
|
rbmDoSampleHidden->setToggleState(m_pLayer->params().gibbsDoSampleHidden, dontSendNotification);
|
||||||
|
|
||||||
weightDecayLabel->setText(String(m_pLayer->params().weightDecay), dontSendNotification);
|
weightDecayLabel->setText(String(m_pLayer->params().l2Lambda), dontSendNotification);
|
||||||
learningRateLabel->setText(String(m_pLayer->params().learningRate), dontSendNotification);
|
learningRateLabel->setText(String(m_pLayer->params().learningRate), dontSendNotification);
|
||||||
momentumLabel->setText(String(m_pLayer->params().momentum), dontSendNotification);
|
momentumLabel->setText(String(m_pLayer->params().momentum), dontSendNotification);
|
||||||
numVisibleLabel->setText(String(m_pLayer->numVisibleX()), dontSendNotification );
|
numVisibleLabel->setText(String(m_pLayer->numVisibleX()), dontSendNotification );
|
||||||
|
|||||||
+5
-5
@@ -367,14 +367,14 @@ void Rbm::train(arma::mat const &batch, IListener* pListener)
|
|||||||
m_bh += inc_bh;
|
m_bh += inc_bh;
|
||||||
m_whv += inc_whv;
|
m_whv += inc_whv;
|
||||||
|
|
||||||
// Weight decay and L1 applied directly to the weights, outside the
|
// L2 and L1 applied directly to the weights, outside the momentum
|
||||||
// momentum recursion above -- folding either into inc_whv would let
|
// recursion above -- folding either into inc_whv would let momentum
|
||||||
// momentum geometrically amplify its effective strength to roughly
|
// geometrically amplify its effective strength to roughly
|
||||||
// lambda/(1-momentum), well past the configured value. Neither
|
// lambda/(1-momentum), well past the configured value. Neither
|
||||||
// touches the biases, matching pyRBM's state_adjust().
|
// touches the biases, matching pyRBM's state_adjust().
|
||||||
if (m_params.weightDecay != 0.0)
|
if (m_params.l2Lambda != 0.0)
|
||||||
{
|
{
|
||||||
m_whv -= m_params.learningRate*m_params.weightDecay*m_whv;
|
m_whv -= m_params.learningRate*m_params.l2Lambda*m_whv;
|
||||||
}
|
}
|
||||||
if (m_params.l1Lambda != 0.0)
|
if (m_params.l1Lambda != 0.0)
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-4
@@ -27,7 +27,7 @@ public:
|
|||||||
{
|
{
|
||||||
Params()
|
Params()
|
||||||
: learningRate(0.1)
|
: learningRate(0.1)
|
||||||
, weightDecay(0.0)
|
, l2Lambda(0.0)
|
||||||
, l1Lambda(0.0)
|
, l1Lambda(0.0)
|
||||||
, momentum(0.9)
|
, momentum(0.9)
|
||||||
, doGaussianHidden(false)
|
, doGaussianHidden(false)
|
||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::cout << "Exporting Rbm::Params" << std::endl;
|
std::cout << "Exporting Rbm::Params" << std::endl;
|
||||||
Json::Value params;
|
Json::Value params;
|
||||||
params["weightDecay"] = weightDecay;
|
params["l2Lambda"] = l2Lambda;
|
||||||
params["l1Lambda"] = l1Lambda;
|
params["l1Lambda"] = l1Lambda;
|
||||||
params["learningRate"] = learningRate;
|
params["learningRate"] = learningRate;
|
||||||
params["momentum"] = momentum;
|
params["momentum"] = momentum;
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
void fromJson(Json::Value params)
|
void fromJson(Json::Value params)
|
||||||
{
|
{
|
||||||
std::cout << "Importing Rbm::Params" << std::endl;
|
std::cout << "Importing Rbm::Params" << std::endl;
|
||||||
weightDecay = params.get("weightDecay", weightDecay).asDouble();
|
l2Lambda = params.get("l2Lambda", l2Lambda).asDouble();
|
||||||
l1Lambda = params.get("l1Lambda", l1Lambda).asDouble();
|
l1Lambda = params.get("l1Lambda", l1Lambda).asDouble();
|
||||||
learningRate = params.get("learningRate", learningRate).asDouble();
|
learningRate = params.get("learningRate", learningRate).asDouble();
|
||||||
momentum = params.get("momentum", momentum).asDouble();
|
momentum = params.get("momentum", momentum).asDouble();
|
||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
numEpochs = params.get("numEpochs", numEpochs).asUInt();
|
numEpochs = params.get("numEpochs", numEpochs).asUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
double weightDecay;
|
double l2Lambda;
|
||||||
double l1Lambda;
|
double l1Lambda;
|
||||||
double learningRate;
|
double learningRate;
|
||||||
double momentum;
|
double momentum;
|
||||||
|
|||||||
Reference in New Issue
Block a user