diff --git a/src/js/ddpg/ddpg.js b/src/js/ddpg/ddpg.js index 4c0eafd..82a93cc 100644 --- a/src/js/ddpg/ddpg.js +++ b/src/js/ddpg/ddpg.js @@ -1,5 +1,5 @@ const { tf } = require('./tf_import') -const {copyModel, Actor, Critic, assignAndStd } = require('./models') +const { copyModel, Actor, Critic, assignAndStd, targetUpdate } = require('./models') function logTfMemory(){ let mem = tf.memory(); @@ -210,7 +210,8 @@ class DDPG { getTfBatch(){ // Get batch const batch = this.memory.popBatch(this.config.batchSize); - // Convert to tensors + + // Convert to tensors const tfActions = tf.tensor2d(batch.actions); const tfObs0 = tf.tensor2d(batch.obs0); const tfObs1 = tf.tensor2d(batch.obs1); diff --git a/src/js/ddpg/ddpg_agent.js b/src/js/ddpg/ddpg_agent.js index bf4ada1..f5c1a6b 100644 --- a/src/js/ddpg/ddpg_agent.js +++ b/src/js/ddpg/ddpg_agent.js @@ -141,8 +141,8 @@ class DDPGAgent { // Get actions const tfActions = this.ddpg.perturbedPrediction(tfPreviousStep); // Step in the environment with theses actions - let mAcions = tfActions.buffer().values; - let [mState, mReward, mDone, info] = this.env.step(mAcions); + let mActions = Array.from(tfActions.buffer().values); + let [mState, mReward, mDone, info] = this.env.step(mActions); this.rewardsList.push(mReward); // Get the new observations let tfState = tf.tensor2d([mState]); @@ -150,7 +150,7 @@ class DDPGAgent { mDone = 1; } // Add the new tuple to the buffer - this.ddpg.memory.append(mPreviousStep, mAcions, mReward, mState, mDone); + this.ddpg.memory.append(mPreviousStep, mActions, mReward, mState, mDone); // Dispose tensors tfPreviousStep.dispose(); tfActions.dispose();