Beispiel #1
0
/// Predict the belief vector that will result if the specified action is performed
void TransitionModel::anticipateNextBeliefs(const GVec& beliefs, const GVec& actions, GVec& anticipatedBeliefs)
{
	if(tutor)
		tutor->transition(beliefs, actions, anticipatedBeliefs);
	else
	{
		GAssert(beliefs.size() + actions.size() == model.layer(0).inputs());
		buf.resize(beliefs.size() + actions.size());
		buf.put(0, beliefs);
		buf.put(beliefs.size(), actions);
		model.forwardProp(buf);
		anticipatedBeliefs.copy(beliefs);
		anticipatedBeliefs.addScaled(2.0, model.outputLayer().activation());
		anticipatedBeliefs.clip(-1.0, 1.0);
	}
}
Beispiel #2
0
/// Refines the beliefs to correspond with actual observations
void ObservationModel::calibrateBeliefs(GVec& beliefs, const GVec& observations)
{
	if(tutor)
		tutor->observations_to_state(observations, beliefs);
	else
	{
		GNeuralNetLayer& layIn = encoder.outputLayer();
		for(size_t i = 0; i < calibrationIters; i++) {
			decoder.forwardProp(beliefs);
			decoder.backpropagate(observations);
			decoder.layer(0).backPropError(&layIn);
			beliefs.addScaled(decoder.learningRate(), layIn.error());
			beliefs.clip(-1.0, 1.0);
		}
	}
}