Learning Embedded Codes