Let's implement a 3-layer deep Convolutional Neural Network (CNN) that takes the Atari game screen pixels as the input and outputs the action-values for each of the possible actions for that particular game, which is defined in the OpenAI Gym environment. The following code is for the CNN class:
import torchclass CNN(torch.nn.Module): """ A Convolution Neural Network (CNN) class to approximate functions with visual/image inputs """ def __init__(self, input_shape, output_shape, device="cpu"): """ :param input_shape: Shape/dimension of the input image. Assumed to be resized to C x 84 x 84 :param output_shape: Shape/dimension of the output. :param device: The device (cpu or cuda) that the ...