def test_multi_feature_single_receiver(self): features = { 'foo': constant_op.constant(5), 'bar': constant_op.constant(6) } receiver_tensor = array_ops.placeholder(dtypes.string) _ = export.ServingInputReceiver(features, receiver_tensor)
def serving_input_receiver_with_asset_fn(): features, receiver_tensor = serving_input_receiver_fn() filename = ops.convert_to_tensor(vocab_file_name, dtypes.string, name='asset_filepath') ops.add_to_collection(ops.GraphKeys.ASSET_FILEPATHS, filename) features['bogus_filename'] = filename return export.ServingInputReceiver(features, receiver_tensor)
def test_multi_feature_multi_receiver(self): features = { 'foo': constant_op.constant(5), 'bar': constant_op.constant(6) } receiver_tensors = { 'baz': array_ops.placeholder(dtypes.int64), 'qux': array_ops.placeholder(dtypes.float32) } _ = export.ServingInputReceiver(features, receiver_tensors)
def test_single_feature_single_receiver(self): feature = constant_op.constant(5) receiver_tensor = array_ops.placeholder(dtypes.string) input_receiver = export.ServingInputReceiver(feature, receiver_tensor) # single feature is automatically named feature_key, = input_receiver.features.keys() self.assertEqual('feature', feature_key) # single receiver is automatically named receiver_key, = input_receiver.receiver_tensors.keys() self.assertEqual('input', receiver_key)
def test_receiver_wrong_type(self): feature = constant_op.constant(5) receiver_tensor = 'not a tensor' with self.assertRaises(ValueError): _ = export.ServingInputReceiver(feature, receiver_tensor)
def test_feature_wrong_type(self): feature = 'not a tensor' receiver_tensor = array_ops.placeholder(dtypes.string) with self.assertRaises(ValueError): _ = export.ServingInputReceiver(feature, receiver_tensor)
def test_multi_feature_multi_receiver(self): features = {"foo": constant_op.constant(5), "bar": constant_op.constant(6)} receiver_tensors = {"baz": array_ops.placeholder(dtypes.int64), "qux": array_ops.placeholder(dtypes.float32)} _ = export.ServingInputReceiver(features, receiver_tensors)