79078633

Date: 2024-10-11 14:31:13
Score: 1
Natty:
Report link
class ParallelDense(Layer):
    def __init__(self, units, **kwargs):
        super().__init__(**kwargs)
        self.units = units

    def build(self, input_shape):
        super().build(input_shape)
        self.kernel = self.add_weight(shape=[input_shape[1], input_shape[2], self.units], trainnable=True, initializer='glorot_uniform')
        self.bias   = self.add_weight(shape=[input_shape[1],                 self.units], trainnable=True, initializer='glorot_uniform')

    def call(self, inputs):
        return tf.einsum("bml, mlk -> bmk", inputs, self.kernel) + self.bias

This : Efficiently use Dense layers in parallel

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: K V