@Test public void testMysoftmax() throws Exception { double[] probabilities = MySoftMaxAfterstatePolicy.mysoftmax(new double[] { 10000, 9900, 10000 }, 100); System.out.print(Arrays.toString(probabilities)); }
static double[] mysoftmax(double[] values, double temperature) { double max = values[0]; for (int i = 1; i < values.length; ++i) { if (max < values[i]) { max = values[i]; } } double[] probabilities = new double[values.length]; double denominator = 0.0; for (int i = 0; i < values.length; ++i) { probabilities[i] = Math.exp((values[i] - max) / max * temperature); denominator += probabilities[i]; } for (int i = 0; i < values.length; ++i) { probabilities[i] /= denominator; } return probabilities; }
MySoftMaxAfterstatePolicy implements VFunctionControlPolicy<S, A> { static double[] mysoftmax(double[] values, double temperature) { double max = values[0]; for (int i = 1; i < values.length; ++i) { if (max < values[i]) { max = values[i]; } } double[] probabilities = new double[values.length]; double denominator = 0.0; for (int i = 0; i < values.length; ++i) { probabilities[i] = Math.exp((values[i] - max) / max * temperature); denominator += probabilities[i]; } for (int i = 0; i < values.length; ++i) { probabilities[i] /= denominator; } return probabilities; } }
MySoftMaxAfterstatePolicy implements VFunctionControlPolicy<S, A> { static double[] mysoftmax(double[] values, double temperature) { double max = values[0]; for (int i = 1; i < values.length; ++i) { if (max < values[i]) { max = values[i]; } } double[] probabilities = new double[values.length]; double denominator = 0.0; for (int i = 0; i < values.length; ++i) { probabilities[i] = Math.exp((values[i] - max) / max * temperature); denominator += probabilities[i]; } for (int i = 0; i < values.length; ++i) { probabilities[i] /= denominator; } return probabilities; } @AccessedViaReflection  MySoftMaxAfterstatePolicy(Environment<S, A> model, double temperature);  MySoftMaxAfterstatePolicy(Environment<S, A> model, double temperature, boolean avoidTerminalStates); }
MySoftMaxAfterstatePolicy implements VFunctionControlPolicy<S, A> { static double[] mysoftmax(double[] values, double temperature) { double max = values[0]; for (int i = 1; i < values.length; ++i) { if (max < values[i]) { max = values[i]; } } double[] probabilities = new double[values.length]; double denominator = 0.0; for (int i = 0; i < values.length; ++i) { probabilities[i] = Math.exp((values[i] - max) / max * temperature); denominator += probabilities[i]; } for (int i = 0; i < values.length; ++i) { probabilities[i] /= denominator; } return probabilities; } @AccessedViaReflection  MySoftMaxAfterstatePolicy(Environment<S, A> model, double temperature);  MySoftMaxAfterstatePolicy(Environment<S, A> model, double temperature, boolean avoidTerminalStates); @Override Decision<A> chooseAction(S state, List<A> actions, StateValueFunction<S> afterStateVFunction,
			RandomDataGenerator random); }
MySoftMaxAfterstatePolicy implements VFunctionControlPolicy<S, A> { static double[] mysoftmax(double[] values, double temperature) { double max = values[0]; for (int i = 1; i < values.length; ++i) { if (max < values[i]) { max = values[i]; } } double[] probabilities = new double[values.length]; double denominator = 0.0; for (int i = 0; i < values.length; ++i) { probabilities[i] = Math.exp((values[i] - max) / max * temperature); denominator += probabilities[i]; } for (int i = 0; i < values.length; ++i) { probabilities[i] /= denominator; } return probabilities; } @AccessedViaReflection  MySoftMaxAfterstatePolicy(Environment<S, A> model, double temperature);  MySoftMaxAfterstatePolicy(Environment<S, A> model, double temperature, boolean avoidTerminalStates); @Override Decision<A> chooseAction(S state, List<A> actions, StateValueFunction<S> afterStateVFunction,
			RandomDataGenerator random);  }