We will learn how to do addition in TensorFlow using tf.add() function.

It can add list, tuple, scaler, TensorFlow variable/constant/placeholder/SparceMatrix with each other and with scaler and with list/tuple.

Note: + operator can be use to add 2 tensors

## Addition of 2 Variables with TensorFlow

```import tensorflow as tf
import numpy as np
```

```a = 10
b = 20
```

```l1 = [1,2,3,4]
l2 = [5,6,7,8]

```

```l1 = [1,2,3,4]
a =10
```

### Addition of 2 list/Tuple with Diiferent Size

If the size of 2 variables is different then tf.add() function will through error. If any one of the variables contains only a single item then it will do the element-wise operation.

```#this code will through error
l1 = [1,2,3,4]
l2 = [5,6]

```

```npa1 = np.array([1,2,3,4,5])
npa2 = np.array([1,2,3,4,5])

```

### Add Numpy array with Scaler

```npa1 = np.array([1,2,3,4,5])
a = 10

```

### Add Numpy array with single element np array

```npa1 = np.array([1,2,3,4,5])
npa2 = np.array([])

```

### Add 2 TF Constant Tensor

```tf_ct1 = tf.constant([1,2,3,4])
tf_ct2 = tf.constant([1,2,3,4])

```

### Add TF Constant Tensor with Scaler

```tf_ct1 = tf.constant([1,2,3,4])
a = 10
```

```tf_vr1 = tf.Variable([1,2,3,4])
tf_vr2 = tf.Variable([1,2,3,4])

```

### Add TF Variable with Scaler

```tf_vr1 = tf.Variable([1,2,3,4])
a = 10
```x = np.ones(6).reshape(1, 2, 1, 3) # (2,2,3,3)