def testSparseCountSparseOutputNegativeValue(self): indices = [[0, 0], [0, 1], [1, 0], [1, 2]] values = [1, 1, -1, 10] dense_shape = [2, 3] with self.assertRaisesRegex(errors.InvalidArgumentError, "Input values must all be non-negative"): self.evaluate( gen_count_ops.SparseCountSparseOutput( indices=indices, values=values, dense_shape=dense_shape, binary_output=False))
def testSparseCountSparseOutputBadIndicesShapeTooSmall(self): indices = [1] values = [[1]] weights = [] dense_shape = [10] with self.assertRaisesRegex(ValueError, "Shape must be rank 2 but is rank 1 for"): self.evaluate( gen_count_ops.SparseCountSparseOutput(indices=indices, values=values, dense_shape=dense_shape, weights=weights, binary_output=True))
def testSparseCountSparseOutputBadNumberOfValues(self): indices = [[0, 0], [0, 1], [1, 0]] values = [1, 1, 1, 10] weights = [1, 2, 4, 6] dense_shape = [2, 3] with self.assertRaisesRegex( errors.InvalidArgumentError, "Number of values must match first dimension of indices"): self.evaluate( gen_count_ops.SparseCountSparseOutput(indices=indices, values=values, dense_shape=dense_shape, weights=weights, binary_output=False))
def testSparseCountSparseOutputBadWeightsShape(self): indices = [[0, 0], [0, 1], [1, 0], [1, 2]] values = [1, 1, 1, 10] weights = [1, 2, 4] dense_shape = [2, 3] with self.assertRaisesRegex( errors.InvalidArgumentError, "Weights and values must have the same shape"): self.evaluate( gen_count_ops.SparseCountSparseOutput(indices=indices, values=values, dense_shape=dense_shape, weights=weights, binary_output=False))
def testSparseCountSparseOutputBadIndicesShape(self): indices = [[[0], [0]], [[0], [1]], [[1], [0]], [[1], [2]]] values = [1, 1, 1, 10] weights = [1, 2, 4, 6] dense_shape = [2, 3] with self.assertRaisesRegex( errors.InvalidArgumentError, "Input indices must be a 2-dimensional tensor"): self.evaluate( gen_count_ops.SparseCountSparseOutput(indices=indices, values=values, dense_shape=dense_shape, weights=weights, binary_output=False))