且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

张量流中的权重和偏差初始化

更新时间:2023-12-02 12:11:16

是否要为RNN单元或密集层设置权重?如果用于RNN单元,则应该能够使用

Do you want to set weights for the RNN Cell or for the Dense layer? If it's for the RNN cell, you should be able to set the weights using the set_weights method.

如果用于密集层,则您应该能够分配 Variable 并使用initializer参数传递您的权重(以及其他偏见).然后,当您调用layers.dense时,可以将变量张量分别传递给kernel_initializerbias_initializer以获得权重和偏差.

If it's for the Dense layer, you should be able to assign a Variable and use the initializer argument to pass your weights (and another for the bias'). Then, when you call layers.dense, you can pass both your variable tensors to kernel_initializer and bias_initializer for weights and biases respectively.