Exercise 1
# UNQ_C1
# GRADED CELL: my_softmax
def my_softmax(z):
""" Softmax converts a vector of values to a probability distribution.
Args:
z (ndarray (N,)) : input data, N features
Returns:
a (ndarray (N,)) : softmax of z
"""
### START CODE HERE ###
n=len(z)
sum=0
a=np.zeros(n,)
for j in range(n):
sum+=np.exp(z[j])
for j in range(n):
a[j]=np.exp(z[j])/sum
### END CODE HERE ###
return a
Exercise 2
# UNQ_C2
# GRADED CELL: Sequential model
tf.random.set_seed(1234) # for consistent results
model = Sequential(
[
### START CODE HERE ###
tf.keras.Input(shape=(400,)),
Dense(units=25, activation='relu'),
Dense(units=15, activation='relu'),
Dense(units=10, activation='linear'),
### END CODE HERE ###
], name = "my_model"
)