简体   繁体   中英

How does tf.layers.dense create the inputs.kernel weight matrix?

Tensorflow document : outputs = activation(inputs.kernel + bias)

  1. The document states kernel is a weights matrix created by the layer, but I cannot find the implementation of kernel in tensorflow/python/layers/core.py . Where will I find the implementation?

----------------------------tl;dr-------------------------------------

From the answer, the shape of weight matrix is defined as shape=[input_shape[-1].value, self.units] Line 886

They have started mixing tf.layers with tf.keras . In you referenced implementation the class inherits all methods from keras_layers

"Following the money", the implementation is here and boils down to

def build(...):
    self.kernel = self.add_variable('kernel', ...
    self.bias = self.add_variable
def call(...):
    # ...
    outputs = gen_math_ops.mat_mul(inputs, self.kernel)
    # ...
    if self.activation is not None:
        return self.activation(outputs)
    return outputs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM