How to create and train a tied autoencoder?

To me, mixed approach looks better.

For the record, I have updated the gist to verify that it works too.