本文整理匯總了Python中official.utils.export.export.build_tensor_serving_input_receiver_fn方法的典型用法代碼示例。如果您正苦於以下問題:Python export.build_tensor_serving_input_receiver_fn方法的具體用法?Python export.build_tensor_serving_input_receiver_fn怎麽用?Python export.build_tensor_serving_input_receiver_fn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類official.utils.export.export
的用法示例。
在下文中一共展示了export.build_tensor_serving_input_receiver_fn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_build_tensor_serving_input_receiver_fn_batch_dtype
# 需要導入模塊: from official.utils.export import export [as 別名]
# 或者: from official.utils.export.export import build_tensor_serving_input_receiver_fn [as 別名]
def test_build_tensor_serving_input_receiver_fn_batch_dtype(self):
receiver_fn = export.build_tensor_serving_input_receiver_fn(
shape=[4, 5], dtype=tf.int8, batch_size=10)
with tf.Graph().as_default():
receiver = receiver_fn()
self.assertIsInstance(
receiver, tf.estimator.export.TensorServingInputReceiver)
self.assertIsInstance(receiver.features, tf.Tensor)
self.assertEqual(receiver.features.shape, tf.TensorShape([10, 4, 5]))
self.assertEqual(receiver.features.dtype, tf.int8)
self.assertIsInstance(receiver.receiver_tensors, dict)
# Note that Python 3 can no longer index .values() directly; cast to list.
self.assertEqual(list(receiver.receiver_tensors.values())[0].shape,
tf.TensorShape([10, 4, 5]))
示例2: test_build_tensor_serving_input_receiver_fn
# 需要導入模塊: from official.utils.export import export [as 別名]
# 或者: from official.utils.export.export import build_tensor_serving_input_receiver_fn [as 別名]
def test_build_tensor_serving_input_receiver_fn(self):
receiver_fn = export.build_tensor_serving_input_receiver_fn(shape=[4, 5])
with tf.Graph().as_default():
receiver = receiver_fn()
self.assertIsInstance(
receiver, tf.estimator.export.TensorServingInputReceiver)
self.assertIsInstance(receiver.features, tf.Tensor)
self.assertEqual(receiver.features.shape, tf.TensorShape([1, 4, 5]))
self.assertEqual(receiver.features.dtype, tf.float32)
self.assertIsInstance(receiver.receiver_tensors, dict)
# Note that Python 3 can no longer index .values() directly; cast to list.
self.assertEqual(list(receiver.receiver_tensors.values())[0].shape,
tf.TensorShape([1, 4, 5]))