0
点赞
收藏
分享

微信扫一扫

吴恩达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"
)

作者:​​楚千羽​​

出处:​​javascript:void(0)​​

本文来自博客园,本文作者:​​楚千羽​​​,转载请注明原文链接:​​javascript:void(0)p/16439088.html​​

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利!



举报

相关推荐

0 条评论