當前位置: 首頁>>代碼示例>>Python>>正文


Python export.build_tensor_serving_input_receiver_fn方法代碼示例

本文整理匯總了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])) 
開發者ID:rockyzhengwu,項目名稱:nsfw,代碼行數:18,代碼來源:export_test.py

示例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])) 
開發者ID:rockyzhengwu,項目名稱:nsfw,代碼行數:16,代碼來源:export_test.py


注:本文中的official.utils.export.export.build_tensor_serving_input_receiver_fn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。