(serializer)
return tl.Fn('Serialize', serialize)
Layer that serializes a given array.
Layer that serializes a given array.
Layer that serializes a given array .
def Serialize(serializer):
  """Layer that serializes a given array."""
  def serialize(x):
    (batch_size, length) = x.shape[:2]
    shape_suffix = x.shape[2:]
    x = jnp.reshape(x, (batch_size * length,) + shape_suffix)
    x = serializer.serialize(x)
    return jnp.reshape(x, (batch_size, -1, serializer.representation_length,))
  return tl.Fn('Serialize', serialize)
def Serialize ( serializer ) : def serialize ( x ) : ( batch_size , length ) = x . shape [ : 2 ] shape_suffix = x . shape [ 2 : ] x = jnp . reshape ( x , ( batch_size * length , ) + shape_suffix ) x = serializer . serialize ( x ) return jnp . reshape ( x , ( batch_size , - 1 , serializer . representation_length , ) ) return tl . Fn ( 'Serialize' , serialize )