(scale=1.0)
return _initializer
LSTM orthogonal initializer.
LSTM orthogonal initializer.
LSTM orthogonal initializer .
def lstm_ortho_initializer(scale=1.0):
  """LSTM orthogonal initializer."""
  def _initializer(shape, dtype=tf.float32,
                   partition_info=None):  # pylint: disable=unused-argument
    size_x = shape[0]
    size_h = shape[1] // 4  # assumes lstm.
    t = np.zeros(shape)
    t[:, :size_h] = orthogonal([size_x, size_h]) * scale
    t[:, size_h:size_h * 2] = orthogonal([size_x, size_h]) * scale
    t[:, size_h * 2:size_h * 3] = orthogonal([size_x, size_h]) * scale
    t[:, size_h * 3:] = orthogonal([size_x, size_h]) * scale
    return tf.constant(t, dtype)

  return _initializer
def lstm_ortho_initializer ( scale = 1.0 ) : def _initializer ( shape , dtype = tf . float32 , partition_info = None ) : # pylint: disable=unused-argument size_x = shape [ 0 ] size_h = shape [ 1 ] // 4 # assumes lstm. t = np . zeros ( shape ) t [ : , : size_h ] = orthogonal ( [ size_x , size_h ] ) * scale t [ : , size_h : size_h * 2 ] = orthogonal ( [ size_x , size_h ] ) * scale t [ : , size_h * 2 : size_h * 3 ] = orthogonal ( [ size_x , size_h ] ) * scale t [ : , size_h * 3 : ] = orthogonal ( [ size_x , size_h ] ) * scale return tf . constant ( t , dtype ) return _initializer