且构网

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

如何在keras模型中使用tf操作

更新时间:2023-12-02 12:37:22

问题1:是的,有必要用一层包装tf操作,因为keras模型需要tensorflow ops不包含的某些函数/变量.在这种情况下,_keras_history是仅通过将op包裹一层而产生的属性.

Question 1: Yes, it is necessary to wrap tf operations with a layer, because keras models require certain functions/variables that aren't included with tensorflow ops. In this case, _keras_history is a property that is only produced by wrapping the op with a layer.

问题2:您是否考虑过使用keras Dense层和use_bias=False进行矩阵乘法?如果您想使用一个常量作为权重向量,则可以设置kernel_initializer={constant}trainable=False.

Question 2: Is the matrix multiplication traHave you considered using a keras Dense layer, with use_bias=False? If you want to use a constant for the weight vector, you could set the kernel_initializer={constant}, and trainable=False.