Skip to Content
Java Deep Learning Projects
book

Java Deep Learning Projects

by Md. Rezaul Karim
June 2018
Intermediate to advanced
436 pages
10h 33m
English
Packt Publishing
Content preview from Java Deep Learning Projects

Calculating the reward

Now that the agent is provided with some guidance—reinforcementthe next task is to calculate the reward for each action the agent makes. Take a look at this code:

// Compute reward for an action float calcReward(float[][] CurrMap, float[][] NextMap) {        int newGoal = calcGoalPos(NextMap);// first, we calculate goal position for each map        if(newGoal == -1) // if goal position is the initial position (i.e. no move)            return (size * size + 1); // we reward the agent to 4*4+ 1 = 17 (i.e. maximum reward)        return -1f; // else we reward -1.0 for each bad move     }
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.
Start your free trial

You might also like

Java Deep Learning Essentials

Java Deep Learning Essentials

Yusuke Sugomori
Machine Learning in Java - Second Edition

Machine Learning in Java - Second Edition

AshishSingh Bhatia, Bostjan Kaluza
Mastering Java Machine Learning

Mastering Java Machine Learning

Uday Kamath, Krishna Choppella

Publisher Resources

ISBN: 9781788997454Supplemental Content