2010-09-16 21:01:23 +04:00
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
|
|
|
Copyright (C) 2010 University of Edinburgh
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
***********************************************************************/
|
|
|
|
|
2010-09-17 13:17:05 +04:00
|
|
|
#include "Optimiser.h"
|
2010-09-16 21:01:23 +04:00
|
|
|
|
|
|
|
using namespace Moses;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace Mira {
|
|
|
|
|
2010-11-30 20:26:34 +03:00
|
|
|
int Perceptron::updateWeights(ScoreComponentCollection& currWeights,
|
2010-12-06 22:32:59 +03:00
|
|
|
const vector< vector<ScoreComponentCollection> >& featureValues,
|
|
|
|
const vector< vector<float> >& losses,
|
2010-12-10 19:34:43 +03:00
|
|
|
const vector< vector<float> >& bleuScores,
|
2010-12-09 14:49:52 +03:00
|
|
|
const vector< ScoreComponentCollection>& oracleFeatureValues,
|
2010-12-10 19:34:43 +03:00
|
|
|
const vector< float> oracleBleuScores,
|
2010-12-09 14:49:52 +03:00
|
|
|
const vector< size_t> dummy)
|
2010-09-16 21:01:23 +04:00
|
|
|
{
|
2010-12-06 22:32:59 +03:00
|
|
|
for (size_t i = 0; i < featureValues.size(); ++i) {
|
|
|
|
for (size_t j = 0; j < featureValues[i].size(); ++j) {
|
2010-10-25 16:22:35 +04:00
|
|
|
if (losses[i][j] > 0) {
|
2010-12-06 22:32:59 +03:00
|
|
|
currWeights.MinusEquals(featureValues[i][j]);
|
|
|
|
currWeights.PlusEquals(oracleFeatureValues[i]);
|
2010-10-25 16:22:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-06 22:32:59 +03:00
|
|
|
|
|
|
|
return 0;
|
2010-09-16 21:01:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|