MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / run_test

Method run_test

tensorflow/python/ops/special_math_ops_test.py:343–368  ·  view source on GitHub ↗
(self, axes, expanded_axes=None)

Source from the content-addressed store, hash-verified

341 _ = special_math_ops.einsum(axes, *inputs)
342
343 def run_test(self, axes, expanded_axes=None):
344 expanded_axes = expanded_axes if expanded_axes is not None else axes
345 all_axes = {ax: np.random.randint(4, 12)
346 for ax in expanded_axes if ax.isalpha()}
347
348 input_vals = []
349 input_axes, _, _ = axes.partition('->')
350
351 for idx in input_axes.split(','):
352 shape = [all_axes[ax] for ax in idx if ax.isalpha()]
353 input_vals.append(np.random.random(shape))
354
355 input_tensors = [constant_op.constant(val) for val in input_vals]
356 output_tensor = special_math_ops.einsum(axes, *input_tensors)
357
358 with self.session(use_gpu=True):
359 output_value = self.evaluate(output_tensor)
360
361 correct_value = 0
362 if axes == 'ijji':
363 output = math_ops.trace(*input_tensors)
364 correct_value = self.evaluate(output)
365 else:
366 correct_value = np.einsum(axes, *input_vals)
367 err = np.abs(correct_value - output_value).max()
368 self.assertLess(err, 1e-8)
369
370 def test_input_is_placeholder(self):
371 with ops.Graph().as_default():

Callers 3

test_simpleMethod · 0.95
test_longMethod · 0.95
test_ellipsisMethod · 0.95

Calls 7

splitMethod · 0.45
appendMethod · 0.45
constantMethod · 0.45
sessionMethod · 0.45
evaluateMethod · 0.45
traceMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected