Get startedGet started for free

Hello nets!

You're going to build a simple neural network to get a feeling of how quickly it is to accomplish this in Keras.

You will build a network that takes two numbers as an input, passes them through a hidden layer of 10 neurons, and finally outputs a single non-constrained number.

A non-constrained output can be obtained by avoiding setting an activation function in the output layer. This is useful for problems like regression, when we want our output to be able to take any non-constrained value.

This exercise is part of the course

Introduction to Deep Learning with Keras

View Course

Exercise instructions

  • Import the Sequential model from tensorflow.keras.models and the Denselayer from tensorflow.keras.layers.
  • Create an instance of the Sequential model.
  • Add a 10-neuron hidden Dense layer with an input_shape of two neurons.
  • Add a final 1-neuron output layer and summarize your model with summary().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the Sequential model and Dense layer
from tensorflow.keras.____ import ____
from tensorflow.keras.____ import ____

# Create a Sequential model
model = ____

# Add an input layer and a hidden layer with 10 neurons
model.add(Dense(____, input_shape=(____,), activation="relu"))

# Add a 1-neuron output layer
model.add(____)

# Summarise your model
model.____
Edit and Run Code