How it works...
As you can see in Step 2, the action estimator has two layers – input and output layers, followed by a sigmoid activation function, and the loss function is binary cross-entropy.
Step 3 is for training the cross-entropy model. Specifically, for each training episode, we take random actions, accumulate rewards, and record states and actions. After experiencing n_episode episodes, we take the most successful episodes (with the highest total rewards) and extract n_samples of (state, action) pairs as training samples. We then train the estimator for 100 iterations on the training set we just constructed.
Executing the lines of code in Step 7 will result in the following plot:
As you can see, there are +200 rewards for all testing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access