MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / getGradientsAndSaveActions

Method getGradientsAndSaveActions

cart-pole/index.js:181–190  ·  view source on GitHub ↗
(inputTensor)

Source from the content-addressed store, hash-verified

179 }
180
181 getGradientsAndSaveActions(inputTensor) {
182 const f = () => tf.tidy(() => {
183 const [logits, actions] = this.getLogitsAndActions(inputTensor);
184 this.currentActions_ = actions.dataSync();
185 const labels =
186 tf.sub(1, tf.tensor2d(this.currentActions_, actions.shape));
187 return tf.losses.sigmoidCrossEntropy(labels, logits).asScalar();
188 });
189 return tf.variableGrads(f);
190 }
191
192 getCurrentActions() {
193 return this.currentActions_;

Callers 1

trainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected