吴恩达Coursera, 机器学习专项课程, Machine Learning:Advanced Learning Algorithms第二周编程作业

吴恩达Coursera, 机器学习专项课程, Machine Learning:Advanced Learning Algorithms第二周所有jupyter notebook文件:

吴恩达,机器学习专项课程, Advanced Learning Algorithms第二周所有Python编程文件

本次作业

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 ### 
    ez = np.exp(z)              #element-wise exponenial
    a = ez/np.sum(ez)
    ### 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,)),    #specify input shape
        Dense(25, activation = 'relu',   name = "L1"),
        Dense(15, activation = 'relu', name = "L2"),
        Dense(10, activation = 'linear', name = "L3")
        ### END CODE HERE ### 
    ], name = "my_model" 
)
posted @ 2022-07-03 01:17  楚千羽  阅读(560)  评论(0编辑  收藏  举报