Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # Architectural parameters of our model
  2. conv = nn.Conv2d
  3. act_fn = nn.ReLU
  4. bn = nn.BatchNorm2d
  5. rec_loss = "mse"
  6.  
  7. # Encoder architecture
  8. enc_fn = create_encoder_denseblock
  9. enc_args = {
  10. "n_dense":3,
  11. "c_start" :4
  12. }
  13.  
  14. # Bottleneck architecture
  15. bn_fn = VAEBottleneck
  16. bn_args = {
  17. "nfs":[128,14]
  18. }
  19.  
  20. # Decoder architecture
  21. dec_fn = create_decoder
  22. dec_args = {
  23. "nfs":[14,64,32,16,8,4,2,1],
  24. "ks":[3,1,3,1,3,1],
  25. "size": 28
  26. }
  27.  
  28. # We create each part of the autoencoder
  29. enc = enc_fn(**enc_args)
  30. bn = bn_fn(**bn_args)
  31. dec = dec_fn(**dec_args)
  32.  
  33. # We wrap the whole thing in a learner, and add a hook for the KL loss
  34. learn = VisionAELearner(data,rec_loss,enc,bn,dec)
  35. kl_hook = VAEHook(learn,beta=1)
  36.  
  37. # We add this code to plot the reconstructions
  38. dec_modules = list(learn.dec[1].children())
  39. learn.set_dec_modules(dec_modules)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement