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

Method call

fashion-mnist-vae/model.js:95–107  ·  view source on GitHub ↗

* The actual computation performed by an instance of ZLayer. * * @param {Tensor[]} inputs this layer takes two input tensors, z_mean and * z_log_var * @return A tensor of the same shape as z_mean and z_log_var, equal to * z_mean + sqrt(exp(z_log_var)) * epsilon, where epsilon

(inputs, kwargs)

Source from the content-addressed store, hash-verified

93 * vector that follows the unit normal distribution (N(0, I)).
94 */
95 call(inputs, kwargs) {
96 const [zMean, zLogVar] = inputs;
97 const batch = zMean.shape[0];
98 const dim = zMean.shape[1];
99
100 const mean = 0;
101 const std = 1.0;
102 // sample epsilon = N(0, I)
103 const epsilon = tf.randomNormal([batch, dim], mean, std);
104
105 // z = z_mean + sqrt(var) * epsilon
106 return zMean.add(zLogVar.mul(0.5).exp().mul(epsilon));
107 }
108
109 static get className() {
110 return 'ZLayer';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected