A neural network system for generating an output image based on one or more training images, the neural network system implemented by one or more computers and comprising: a recurrent neural network that is configured to, for each time step of a predetermined number of time steps, receive a set of latent variables for the time step, the latent variables being obtained from the one or more training images during training, and process the set of latent variables to update a hidden state of the recurrent neural network; and a generative subsystem that is configured to: for each time step of the predetermined number of time steps: generate the set of latent variables for the time step and provide the set of latent variables as input to the recurrent neural network; update a hidden canvas using the updated hidden state of the recurrent neural network, the hidden canvas comprising a set of hidden variables that represent characteristics of the one or more training images; and only for a last time step of the predetermined number of time steps: generate the output image using the updated hidden canvas for the last time step by: mapping the updated hidden canvas for the last time step to sufficient statistics of a likelihood model using an observation function, wherein either, when the hidden canvas has the same spatial dimensions as the output image, the observation function is a 1×1 convolution that is applied over the hidden canvas or, when the hidden canvas has different spatial dimensions from the output image, the observation function is one or more convolutional layers that generate an output feature map having the spatial dimensions of the output image from the hidden canvas; and generating the output image by sampling from the likelihood model. a recurrent neural network that is configured to, for each time step of a predetermined number of time steps, receive a set of latent variables for the time step, the latent variables being obtained from the one or more training images during training, and process the set of latent variables to update a hidden state of the recurrent neural network; and a generative subsystem that is configured to: for each time step of the predetermined number of time steps: generate the set of latent variables for the time step and provide the set of latent variables as input to the recurrent neural network; update a hidden canvas using the updated hidden state of the recurrent neural network, the hidden canvas comprising a set of hidden variables that represent characteristics of the one or more training images; and only for a last time step of the predetermined number of time steps: generate the output image using the updated hidden canvas for the last time step by: for each time step of the predetermined number of time steps: generate the set of latent variables for the time step and provide the set of latent variables as input to the recurrent neural network; update a hidden canvas using the updated hidden state of the recurrent neural network, the hidden canvas comprising a set of hidden variables that represent characteristics of the one or more training images; and generate the set of latent variables for the time step and provide the set of latent variables as input to the recurrent neural network; update a hidden canvas using the updated hidden state of the recurrent neural network, the hidden canvas comprising a set of hidden variables that represent characteristics of the one or more training images; and only for a last time step of the predetermined number of time steps: generate the output image using the updated hidden canvas for the last time step by: mapping the updated hidden canvas for the last time step to sufficient statistics of a likelihood model using an observation function, wherein either, when the hidden canvas has the same spatial dimensions as the output image, the observation function is a 1×1 convolution that is applied over the hidden canvas or, when the hidden canvas has different spatial dimensions from the output image, the observation function is one or more convolutional layers that generate an output feature map having the spatial dimensions of the output image from the hidden canvas; and generating the output image by sampling from the likelihood model.