Keras设置以及获取权重的实现
作者:silent56_th 时间:2021-11-22 10:04:09
layer的两个函数:
get_weights(), set_weights(weights)。
详情请参考about-keras-layers。
补充知识:Keras层的共同函数
关于Keras层:
所有Keras层都有很多共同的函数:
layer.get_weights(): # 以Numpy矩阵的形式返回层的权重。
layer.set_weights(weights): # 从Numpy矩阵中设置层的权重(与get_weights的输出形状相同)。
layer.get_config(): # 返回包含层配置的字典。
图层的重置:
layer = Dense(32)
config = layer.get_config()
reconstructed_layer = Dense.from_config(config)
#
from keras import layers
config = layer.get_config()
layer = layers.deserialize({'class_name': layer.__class__.__name__,
'config': config})
如果一个层具有单个节点, (i.e. 如果它不是共享层), 可以得到它的输入张量,输出张量,输入尺寸和输出尺寸:
layer.input
layer.output
layer.input_shape
layer.output_shape
如果层有多个节点 (层节点和共享层), 可以使用以下函数: 要指明再哪个节点处获得张量,哪个节点处获得张量尺寸。
layer.get_input_at(node_index)
layer.get_output_at(node_index)
layer.get_input_shape_at(node_index)
layer.get_output_shape_at(node_index)
来源:https://blog.csdn.net/silent56_th/article/details/61663548
标签:Keras,设置,权重
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
PHP简单实现正则匹配省市区的方法
2023-11-14 22:24:09
Python类型转换的魔术方法详解
2022-04-16 12:49:06
python感知机实现代码
2022-03-12 14:59:50
![](https://img.aspxhome.com/file/2023/1/72871_0s.jpg)
asp 自定义分段函数/求第N名成绩
2011-03-25 11:07:00
从SNS看社会化界面设计 I
2009-02-19 12:21:00
![](https://img.aspxhome.com/file/UploadPic/20092/19/01-43s.jpg)
Python更换pip源方法过程解析
2022-01-20 08:00:58
![](https://img.aspxhome.com/file/2023/5/78745_0s.png)
浅谈flask源码之请求过程
2023-12-17 10:36:48
Python流程控制语句详解
2022-03-01 22:36:37
![](https://img.aspxhome.com/file/2023/0/92370_0s.jpg)
浏览器 cookie 限制
2008-05-23 13:09:00
Python实现 PS 图像调整中的亮度调整
2021-04-02 20:08:54
Yahoo!网站性能最佳体验的34条黄金守则—内容
2008-05-13 12:14:00
![](https://img.aspxhome.com/file/UploadPic/up/2008052914062462.gif)
django实现模板中的字符串文字和自动转义
2023-10-18 16:49:46
根据选择的checkbox列出选择的值
2008-07-30 12:56:00
![](https://img.aspxhome.com/file/UploadPic/20087/30/200873013437517s.jpg)
PHP PDOStatement::getAttribute讲解
2023-06-05 07:29:31
css利用锚点控制翻页
2008-07-17 13:12:00
![](https://img.aspxhome.com/file/UploadPic/20087/17/200871713205636s.gif)
ASP实现SQL语句日期格式的加减运算
2008-11-07 15:13:00
asp日历代码 显示农历
2007-09-23 08:40:00
php生成与读取excel文件
2023-11-15 06:17:48
Python多进程fork()函数详解
2023-06-08 19:41:37
python 对txt中每行内容进行批量替换的方法
2022-12-29 21:37:45
![](https://img.aspxhome.com/file/2023/1/67841_0s.jpg)