* 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)
| 122 | * @param {number} opts.latentDim number of dimensions in latent space |
| 123 | */ |
| 124 | function 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. |
no test coverage detected