In life we have to process inputs of different types; images, text, numbers, etc. and neural networks can too.

For example, let’s suppose we want to build a network that predicts house prices using location data, attributes, and images. The process would look something like this:

Image for post

Figure 1. Neural network data flow

We will work with a simplified example. We will input an image with either an X or an I, and numerical data with either a 0 or a 1. The outputs are shown in the following table:

Image for post

Figure 2. Input-Output table

So, if we add an image with an X and the number 0 we get an output of 1.

Before starting to build our network, we import the required libraries:

import numpy as np
import random
import tensorflow as tf
from tensorflow import keras

Building our data

Let’s start by building our input data. We will create the two 3x3, black and white images.

#0 is black, 255 is white.
X_image = [[0,255,0],[255,0,255],[0,255,0]]
I_image = [[255,0,255],[255,0,255],[255,0,255]]

Image for post

Figure 3. X and I, increased 100x in size.

We will now create our data.

#keras #deep-learning #deep learning

Adding mixed shaped inputs to a neural network.
2.05 GEEK