
org.deeplearning4j.rl4j.space.HighLowDiscrete Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gym-java-client Show documentation
Show all versions of gym-java-client Show documentation
A Java client for Open AI's Reinforcement Learning Gym
package org.deeplearning4j.rl4j.space;
import lombok.Value;
import org.json.JSONArray;
import org.nd4j.linalg.api.ndarray.INDArray;
/**
* @author rubenfiszel ([email protected]) on 7/26/16.
*/
@Value
public class HighLowDiscrete extends DiscreteSpace {
//size of the space also defined as the number of different actions
INDArray matrix;
public HighLowDiscrete(INDArray matrix) {
super(matrix.rows());
this.matrix = matrix;
}
@Override
public Object encode(Integer a){
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < size; i++) {
jsonArray.put(matrix.getDouble(i, 0));
}
jsonArray.put(a-1, matrix.getDouble(a-1, 1));
return jsonArray;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy