MCPcopy Create free account
hub / github.com/google-research/language / zeros_numpy_array

Method zeros_numpy_array

language/nql/nql/__init__.py:884–900  ·  view source on GitHub ↗

A zero valued row vector encoding this entity. Args: type_name: the string type name of the named entity as_matrix: if true, return a 1-by-N matrix instead of a vector. Returns: A numpy array. If as_matrix is True, the array has shape (1,n) where n is the number of

(self,
                        type_name,
                        as_matrix = True)

Source from the content-addressed store, hash-verified

882 return self.as_nql(np_vec, type_name, provenance)
883
884 def zeros_numpy_array(self,
885 type_name,
886 as_matrix = True):
887 """A zero valued row vector encoding this entity.
888
889 Args:
890 type_name: the string type name of the named entity
891 as_matrix: if true, return a 1-by-N matrix instead of a vector.
892
893 Returns:
894 A numpy array. If as_matrix is True, the array has shape (1,n)
895 where n is the number of columns, else the shape is (n,).
896 """
897 if as_matrix:
898 return np.zeros((1, self.get_max_id(type_name)), dtype='float32')
899 else:
900 return np.zeros((self.get_max_id(type_name),), dtype='float32')
901
902 def one_hot_numpy_array(self, entity_name,
903 type_name):

Callers 2

noneMethod · 0.95
one_hot_numpy_arrayMethod · 0.95

Calls 1

get_max_idMethod · 0.95

Tested by

no test coverage detected