当前位置:网站首页>【头歌】重生之深度学习篇-Keras(初级)
【头歌】重生之深度学习篇-Keras(初级)
2022-07-27 05:19:00 【垮起个老脸】
创作不易,参考之前,点个赞,收藏,关注一下不过分吧,家人们
第1关:构建模型
任务描述
本关任务:
构建一个简单的模型,并且指定输入数据的尺寸:batch_size 为18,input_dim 为20。
编程要求
根据提示,在右侧编辑器补充代码,构建一个简单的模型,并指定输入输出数据的尺寸:units为18,input_dim 为20。
def input_values():
model = Sequential()
'''
返回值:
model: 一个顺序模型
'''
# 请在此添加代码 完成本关任务
# ********** Begin *********#
model.add(Dense(units=18,input_dim=20))
# ********** End **********#
# 返回model
return model第2关:Keras模型编译
任务描述
本关任务:构建一个简单的模型,并对模型进行编译
编程要求
根据提示,在右侧编辑器补充代码,进而对模型进行编译,要求如下:
提示:optimizer 为 'rmsprop',loss 为 'binary_crossentropy',metrics 为 'accuracy'.
model.add(Dense(1, activation='sigmoid'))
'''
返回值:
model: 一个顺序模型
'''
# 请在此添加代码 完成本关任务
# ********** Begin *********#
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',
metrics=['accuracy'])
# ********** End **********#
# 返回model
return model
compile_model()第3关:训练模型
任务描述
本关任务:构建一个简单的模型,对模型进行训练。
编程要求
根据提示,在右侧编辑器补充代码,进而对模型进行训练,要求如下:
提示:将随机生成的1000组数据都作为训练集建议迭代轮次为10建议每次更新的样本数为64.
# 生成虚拟数据
data = np.random.random((1000, 100))
labels = np.random.randint(2, size=(1000, 1))
'''
返回值:
model: 一个顺序模型
'''
# 请在此添加代码 完成本关任务
# ********** Begin *********#
model.fit(data,labels,epochs=10,batch_size=64)
# ********** End **********#
# 返回model
return model
注:内容只做参考和分享,未经允许不可传播,侵权立删
边栏推荐
猜你喜欢

Chrome 如何快速将一组正在浏览的网页(tabs)转移到另一台设备(电脑)上

基于深度神经网络的社交媒体用户级心理压力检测

10. Gradient, activation function and loss

cycleGAN解析

13.逻辑回归

数字图像处理第四章——频率域滤波

Digital image processing Chapter 8 - image compression

Social media user level psychological stress detection based on deep neural network

A photo breaks through the face recognition system: you can nod your head and open your mouth, netizens

8. Mathematical operation and attribute statistics
随机推荐
代码随想录笔记_哈希_242有效的字母异位词
socket编程二:使用select
Rk3399 GPIO port how to find which GPIO port it is
西瓜书学习第五章---神经网络
Cap principle
导数、偏导数以及梯度
Only one looper may be created per thread
舆情&传染病时空分析文献阅读笔记
2.简单回归问题
GBASE 8C——SQL参考6 sql语法(10)
pytorch模型
16. Over fitting and under fitting
图像超分辨率评价指标
GBASE 8C——SQL参考6 sql语法(9)
新冠时空分析——Global evidence of expressed sentiment alterations during the COVID-19 pandemic
Gbase 8C - SQL reference 6 SQL syntax (3)
Day 7. Towards Preemptive Detection of Depression and Anxiety in Twitter
Gbase 8C - SQL reference 6 SQL syntax (5)
Day 8.Developing Simplified Chinese Psychological Linguistic Analysis Dictionary for Microblog
SoK: The Faults in our ASRs: An Overview of Attacks against Automatic Speech Recognition (题目过长)阅读笔记