1
$\begingroup$

Assuming a relation such that $y = f(x)$, where $y$ represents a scalar and $x \in 20 \times 1$ vector consisting of zeros and ones, I want to set up a reinforcement learning model that changes the values of the elements of $x$ in order to maximize the $y$.

Let's assume that $y = f(x)$ is equal to

weights = np.random.uniform(-1, 1, 20) 
y       = np.sum(weights*x)

How do I set up such model?

In my implementation, I am using keras API and I am trying to adapt the cartpole case code (https://keras.io/examples/rl/actor_critic_cartpole/). However, this code solves for a different problem since the model can perform only one action that can assume discrete values.

Secondarily, is it appropriate to set as a reward function simply $y$?. The following code reports how I would structure the architectures.

num_inputs = 20
num_actions = 2
num_hidden = 128

inputs = layers.Input(shape=(num_inputs,))
common = layers.Dense(num_hidden, activation="relu")(inputs)
action = layers.Dense(num_actions, activation="softmax")(common)
critic = layers.Dense(1)(common)

model = keras.Model(inputs=inputs, outputs=[action, critic])

However, how can I control the fact that the input parameters could assume only discrete values (0 and 1)?

$\endgroup$

1 Answer 1

1
$\begingroup$

Sure your idea makes sense to me. Yes you can give y as the reward.

No need to control for the fact that the input has only discrete values 0 and 1. Technically, most RL codes would normalize the input (using the running totals, obviously), but that's an optional step that works as heuristic, it's not technically needed.

Interested to hear the results of your experiment.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .