DataScience 板


LINE

作业系统: Win 10 问题类别: ML, RNN, GRU 使用工具: Python3, Keras 问题内容: 想请问各位大大: 最近在尝试不同的时间序列模型,架构如下图。 想请问如果我先将Input输入,并且训练完完整的模型,再将Input输入第二次,然後想要 取得第三层(也就是下图绿色那层GRU)的输出,我应该怎麽拿? 而且我将Input输入第二次时,不希望第一层和第二层GRU的神经元权重被更改。 https://i.imgur.com/piVLJ8n.jpg 也就是我要将资料丢入训练好的完整模型,但我只要资料到第三层的时候的输出。 我目前的Code: 完整的模型架构如下: ## Input Layer input = Input(shape=(look_back,trainX.shape[2]),name='M1_input') ## Hidden Layer Layer1 = GRU(64, return_sequences=True, name='M1_GRU1')(input) Layer2 = GRU(32, return_sequences=True, name='M1_GRU2')(Layer1) Layer3 = GRU(16, return_sequences=True, name='M1_GRU3')(Layer2) Layer4 = GRU(32, return_sequences=True, name='M1_GRU4')(Layer3) Layer5 = GRU(64, name='M1_GRU5')(Layer4) ## Output Layer output = Dense(69,activation='relu', name='M1_output')(Layer5) model1 = Model(inputs=input,outputs=output) ## Model compile model1.compile(loss='mean_absolute_error', optimizer='adam',metrics=['mse','ma pe']) model1.summary() 我取用第三的输出方式如下: mid_layer1 = K.function([model1.layers[0].input], [model1.layers[3].output]) mid_layer1_train_output = mid_layer1([trainX])[0] 想请问我这样拿到的是『完整训练过一次的第三层输出』,还是『训练到第三层的时候的 输出』? 如果是训练到第三层的时候的输出,我应该要怎麽要取得『完整训练过一次的第三层输出 』? 我是不是需要用到Freeze Layer之类的用法? 请各位大大指导,谢谢!!! --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.134.198.86
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/DataScience/M.1556717582.A.1E8.html ※ 编辑: adam100830 (220.134.198.86), 05/01/2019 21:33:45
1F:→ thefattiger: 不就train完之後第三层的输出...?05/02 15:55
2F:→ thefattiger: 其实看不是很懂你想问啥,看下面这有没有帮到你 05/02 15:55
3F:→ thefattiger: https://reurl.cc/EYlGg05/02 15:58
4F:→ sxy67230: 稍微看了一下,你这个是Keras吧,K.function是直接呼叫k05/02 18:34
5F:→ sxy67230: eras call,keras在根据你的当前参数输出你的对应层数05/02 18:34
6F:→ sxy67230: 输出05/02 18:34
7F:→ sxy67230: 回到正题,你没呼叫gradient ,那keras就是依照你的初始 05/02 18:37
8F:→ sxy67230: 参数直接给第三层的output,k.function跟k.gradient都是05/02 18:37
9F:→ sxy67230: keras封装tensorflow或theano的呼叫。05/02 18:37
10F:→ sxy67230: 如果你今天fit完,在呼叫k.function就是train完的第三层 05/02 18:42
11F:→ sxy67230: 输出。你用k.gradient叠二十次就是gradient更新你20次训05/02 18:42
12F:→ sxy67230: 练的第三层输出。 05/02 18:42
※ 编辑: adam100830 (220.134.198.86), 05/02/2019 19:28:03
13F:推 bulc381: m = Model(model1.inputs, model1.layers[3].output) 05/04 01:45
14F:→ bulc381: y = m.predict(X_train) 没必要用到backend function 05/04 01:46
15F:→ bulc381: trainX 05/04 01:46
16F:推 goldflower: 同楼上 用两个model就好 05/05 18:40







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP