* The combined encoder-decoder pipeline. * * @param {tf.Model} encoder * @param {tf.Model} decoder * * @returns {tf.Model} the vae.
(encoder, decoder)
| 153 | * @returns {tf.Model} the vae. |
| 154 | */ |
| 155 | function vae(encoder, decoder) { |
| 156 | const inputs = encoder.inputs; |
| 157 | const encoderOutputs = encoder.apply(inputs); |
| 158 | const encoded = encoderOutputs[2]; |
| 159 | const decoderOutput = decoder.apply(encoded); |
| 160 | const v = tf.model({ |
| 161 | inputs: inputs, |
| 162 | outputs: [decoderOutput, ...encoderOutputs], |
| 163 | name: 'vae_mlp', |
| 164 | }) |
| 165 | |
| 166 | // console.log('VAE Summary'); |
| 167 | // v.summary(); |
| 168 | return v; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * The custom loss function for VAE. |
no test coverage detected