tf.layers.SharedWeightsDenseLayer module

tf.layers.SharedWeightsDenseLayer module

class tf.layers.SharedWeightsDenseLayer.SharedWeightsDenseLayer(*args: Any, **kwargs: Any)

Bases: modelzoo.common.tf.layers.BaseLayer.BaseLayer

Dense layer that takes in a kernel as a shared weight. Can also optionally add a bias.

call(inputs, kernel, transpose_kernel=True, **kwargs)

Apply the densely-connected layer.

Parameters
  • inputs (Tensor) – An N-D tensor with the shape: (batch_size, ..., input_dim).

  • kernel (Tensor) – A 2-D tensor with the shape: (units, input_dim). The dense kernel.

  • transpose_kernel (bool) – Whether to transpose the kernel when performing tf.matmul(inputs, kernel).

Returns

An N-D tensor with shape: (batch_size, ..., units).

Return type

Tensor