MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / tensor2numpy

Function tensor2numpy

NLP/Text2SQL-BASELINE/text2sql/utils/nn_utils.py:181–205  ·  view source on GitHub ↗

Args: inputs (TYPE): NULL Returns: TODO Raises: NULL

(inputs)

Source from the content-addressed store, hash-verified

179
180
181def tensor2numpy(inputs):
182 """
183
184 Args:
185 inputs (TYPE): NULL
186
187 Returns: TODO
188
189 Raises: NULL
190 """
191 if type(inputs) in (list, tuple):
192 return [x.numpy() for x in inputs]
193 elif type(inputs) is dict:
194 outputs = {}
195 for key, value in inputs.items():
196 if type(value) is paddle.Tensor:
197 outputs[key] = value.numpy()
198 else:
199 outputs[key] = value
200 return outputs
201 elif type(inputs) is paddle.Tensor:
202 return inputs.numpy()
203 else:
204 raise ValueError('only support inputs to be of type list/tuple/dict/Tensor.' + \
205 f'but got {type(inputs)}')
206
207
208if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected