# Variables

The second component necessary for building a deep learning model. Variables need to be appropriate for the data you expect to input for the model.

Variables are used as inputs to models and loss functions - they are placeholders for what you dataset inputs and targets will look like. The variables are passed with the form Tuple(shape_monad, theano_variable):

## Shape monad

The first element in the tuple when passing variables or expressions around Model inputs is the shape monad. This is a tuple whose length is equal to the number of dimensions, and each element corresponds to that dimension's size. If any size is unknown, simply put None as the element. Here is an example shape for minibatch processing on MNIST 2D images:

```
# mnist images are greyscale i.e. there is only 1 color channel
h, w = 28, 28
channels = 1
batch_size = None
shape_monad = (batch_size, channels, h, w)
```

## Theano tensor

Now that we have the shape we expect our input to be, we have to create a Theano tensor variable to represent it. Use the appropriate constructor from Theano's documentation, and be sure that the type of the variable is appropriate for the type of the input. To continue our MNIST example, here is the appropriate Theano tensor to initialize:

```
# initialize the 4D tensor that represents batches of images
images = theano.tensor.tensor4(name="images", dtype='float32')
```

## Putting it together

Whenever we pass this new variable representing batches of images, we construct it with a tuple as follows:

```
# variable tuple to pass as input to model
input = (shape_monad, images)
```

Updated less than a minute ago