Tensorflow
Basic Dense Network Model
Instantiate a Dense network model with a single layer, the simplest possible model Tensorflow can support. This configuration will have:
input_shape=[1]
- Input to this layer is a single value, the shape of this model is a one-dimensional array with one member. Since this is the only layer, it is the shape of the entire model.units=1
- Specifieds number of neurons in the layer. How many internal variables the layer has to try to learn how to solve the problem. Since this is the final layer, it is also the size of the model's outputSequential model - Takes a list of layers as an argument specifying calculation order from input to output
Loss function - a way of measuring how far off predictions are from the desired outcome. In this case we'll use
mean_squared_error
Optimizer function - A way of adjusting the internal values in order to reduce the loss. In this case we'll use
Adam
In this case we'll give it a learning rate of 0.1 but it is important to consider. If the learning rate is too small then it will take too long to train, too large and it will be inaccurate. Finding an optimal value for your use case can involve trial and error.
Dense Layers
In basic terms, all neurons from one layer are connected to the neurons from the previous layer and the next layer, or fully connected.
The following weights (w's) and variables (b) are changed iteratively during the training process until the final values are very close to correct.
The 1 layer Dense network we established previously to learn the equation for Celsius to Fahrenheit pretty much looks like this:
Last updated
Was this helpful?