我有以下代码块:
^{1}$以及:
^{pr2}$所以我们可以观察到滤波器的尺寸是3x3,滤波器的数目是8。滤波器用随机值定义。在
我需要做的是用固定值定义我所有的8个过滤器,即预定值,例如:
weigths = [
[[0, 1, 0,],[0, -1, 0,],[0, 0, 0,],],
[[0, 0, 1,],[0, -1, 0,],[0, 0, 0,],],
[[0, 0, 0,],[0, -1, 1,],[0, 0, 0,],],
[[0, 0, 0,],[0, -1, 0,],[0, 0, 1,],],
[[0, 0, 0,],[0, -1, 0,],[0, 1, 0,],],
[[0, 0, 0,],[0, -1, 0,],[1, 0, 0,],],
[[0, 0, 0,],[1, -1, 0,],[0, 0, 0,],],
[[1, 0, 0,],[0, -1, 0,],[0, 0, 0,],]
]
我无法想象,我怎么能在我的代码里做这个修改,有人知道我怎么做吗?在
提前非常感谢!在
您只需将权重定义为不可训练,并将新权重定义为:
如果您想通过某个预定义的值初始化权重,可以使用
tf.constant_initializer
。如果您不想训练这个权重,可以将它们定义为tf.constant
而不是tf.Variable
相关问题 更多 >
编程相关推荐