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

Function decoder

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

* The decoder portion of the model. * * @param {*} opts decoder configuration * @param {number} opts.originalDim number of dimensions in the original data * @param {number} opts.intermediateDim number of dimensions in the bottleneck * of the encoder * @para

(opts)

Source from the content-addressed store, hash-verified

122 * @param {number} opts.latentDim number of dimensions in latent space
123 */
124function decoder(opts) {
125 const {originalDim, intermediateDim, latentDim} = opts;
126
127 // The decoder model has a linear topology and hence could be constructed
128 // with `tf.sequential()`. But we use the functional-model API (i.e.,
129 // `tf.model()`) here nonetheless, for consistency with the encoder model
130 // (see `encoder()` above).
131 const input = tf.input({shape: [latentDim]});
132 let y = tf.layers.dense({
133 units: intermediateDim,
134 activation: 'relu'
135 }).apply(input);
136 y = tf.layers.dense({
137 units: originalDim,
138 activation: 'sigmoid'
139 }).apply(y);
140 const dec = tf.model({inputs: input, outputs: y});
141
142 // console.log('Decoder Summary');
143 // dec.summary();
144 return dec;
145}
146
147/**
148 * The combined encoder-decoder pipeline.

Callers 2

model_test.jsFile · 0.85
trainFunction · 0.85

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected