(decode_fn, matrix)
Decode a matrix or vector.
Decode a matrix or vector.
Decode a matrix or vector .
def decode_matrix(decode_fn, matrix):
  """Decode a matrix or vector."""
  if np.issubdtype(matrix.dtype, float):
    decode_fn = str
  num_dims = len(matrix.shape)
  if num_dims == 1:
    return decode_fn(matrix)
  elif num_dims == 2:
    return [decode_fn(v) for v in matrix]
  else:
    raise ValueError("Matrix dimensions has to be 1 or 2, got %d" % num_dims)
def decode_matrix ( decode_fn , matrix ) : if np . issubdtype ( matrix . dtype , float ) : decode_fn = str num_dims = len ( matrix . shape ) if num_dims == 1 : return decode_fn ( matrix ) elif num_dims == 2 : return [ decode_fn ( v ) for v in matrix ] else : raise ValueError ( "Matrix dimensions has to be 1 or 2, got %d" % num_dims )