def test_serving_input_receiver_features_invalid(self): receiver_tensors = { "example0": tf.constant(["test0"], name="example0"), u"example1": tf.constant(["test1"], name="example1"), } with self.assertRaisesRegexp(ValueError, "features must be defined"): export.TensorServingInputReceiver( features=None, receiver_tensors=receiver_tensors) with self.assertRaisesRegexp(ValueError, "feature must be a Tensor"): export.TensorServingInputReceiver( features={"1": tf.constant([1])}, receiver_tensors=receiver_tensors)
def test_serving_input_receiver_features_invalid(self): receiver_tensors = { "example0": array_ops.placeholder(dtypes.string, name="example0"), u"example1": array_ops.placeholder(dtypes.string, name="example1"), } with self.assertRaisesRegexp(ValueError, "features must be defined"): export.TensorServingInputReceiver( features=None, receiver_tensors=receiver_tensors) with self.assertRaisesRegexp(ValueError, "feature must be a Tensor"): export.TensorServingInputReceiver( features={"1": constant_op.constant([1])}, receiver_tensors=receiver_tensors)
def test_serving_input_receiver_receiver_tensors_invalid(self): features = tf.constant([0]) with self.assertRaisesRegexp(ValueError, "receiver_tensors must be defined"): export.TensorServingInputReceiver( features=features, receiver_tensors=None) with self.assertRaisesRegexp(ValueError, "receiver_tensor keys must be strings"): export.TensorServingInputReceiver( features=features, receiver_tensors={1: tf.constant(["test"], name="example0")}) with self.assertRaisesRegexp(ValueError, "receiver_tensor example1 must be a Tensor"): export.TensorServingInputReceiver( features=features, receiver_tensors={"example1": [1]})
def test_tensor_serving_input_receiver_constructor(self): features = tf.constant([0]) receiver_tensors = { "example0": tf.constant(["test0"], name="example0"), u"example1": tf.constant(["test1"], name="example1"), } r = export.TensorServingInputReceiver(features, receiver_tensors) self.assertIsInstance(r.features, tf.Tensor) self.assertIsInstance(r.receiver_tensors, dict)
def test_tensor_serving_input_receiver_constructor(self): features = constant_op.constant([0]) receiver_tensors = { "example0": array_ops.placeholder(dtypes.string, name="example0"), u"example1": array_ops.placeholder(dtypes.string, name="example1"), } r = export.TensorServingInputReceiver(features, receiver_tensors) self.assertTrue(isinstance(r.features, ops.Tensor)) self.assertTrue(isinstance(r.receiver_tensors, dict))
def test_tensor_serving_input_receiver_sparse(self): features = tf.sparse.SparseTensor( indices=[[0, 0]], values=[1], dense_shape=[1, 1]) receiver_tensors = { "example0": tf.constant(["test0"], name="example0"), u"example1": tf.constant(["test1"], name="example1"), } r = export.TensorServingInputReceiver(features, receiver_tensors) self.assertIsInstance(r.features, tf.sparse.SparseTensor) self.assertIsInstance(r.receiver_tensors, dict)
def test_tensor_serving_input_receiver_sparse(self): features = sparse_tensor.SparseTensor(indices=[[0, 0]], values=[1], dense_shape=[1, 1]) receiver_tensors = { "example0": array_ops.placeholder(dtypes.string, name="example0"), u"example1": array_ops.placeholder(dtypes.string, name="example1"), } r = export.TensorServingInputReceiver(features, receiver_tensors) self.assertTrue(isinstance(r.features, sparse_tensor.SparseTensor)) self.assertTrue(isinstance(r.receiver_tensors, dict))