当前位置: 首页>>代码示例>>Python>>正文


Python errors.InvalidArgumentError方法代码示例

本文整理汇总了Python中tensorflow.python.framework.errors.InvalidArgumentError方法的典型用法代码示例。如果您正苦于以下问题:Python errors.InvalidArgumentError方法的具体用法?Python errors.InvalidArgumentError怎么用?Python errors.InvalidArgumentError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.python.framework.errors的用法示例。


在下文中一共展示了errors.InvalidArgumentError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sort_by_field_invalid_inputs

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def test_sort_by_field_invalid_inputs(self):
    corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 *
                           [3.0], 4 * [4.0]])
    misc = tf.constant([[.95, .9], [.5, .3]], tf.float32)
    weights = tf.constant([.1, .2], tf.float32)
    boxes = box_list.BoxList(corners)
    boxes.add_field('misc', misc)
    boxes.add_field('weights', weights)

    with self.test_session() as sess:
      with self.assertRaises(ValueError):
        box_list_ops.sort_by_field(boxes, 'area')

      with self.assertRaises(ValueError):
        box_list_ops.sort_by_field(boxes, 'misc')

      with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError,
                                               'Incorrect field size'):
        sess.run(box_list_ops.sort_by_field(boxes, 'weights').get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:box_list_ops_test.py

示例2: test_with_invalid_scores_field

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def test_with_invalid_scores_field(self):
    corners = tf.constant([[0, 0, 1, 1],
                           [0, 0.1, 1, 1.1],
                           [0, -0.1, 1, 0.9],
                           [0, 10, 1, 11],
                           [0, 10.1, 1, 11.1],
                           [0, 100, 1, 101]], tf.float32)
    boxes = box_list.BoxList(corners)
    boxes.add_field('scores', tf.constant([.9, .75, .6, .95, .5]))
    iou_thresh = .5
    max_output_size = 3
    nms = box_list_ops.non_max_suppression(
        boxes, iou_thresh, max_output_size)
    with self.test_session() as sess:
      with self.assertRaisesWithPredicateMatch(
          errors.InvalidArgumentError, 'scores has incompatible shape'):
        sess.run(nms.get()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:box_list_ops_test.py

示例3: make_request_json

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def make_request_json(self, uri, output_json):
    """Produces a JSON request suitable to send to CloudML Prediction API.

    Args:
      uri: The input image URI.
      output_json: File handle of the output json where request will be written.
    """
    def _open_file_read_binary(uri):
      try:
        return file_io.FileIO(uri, mode='rb')
      except errors.InvalidArgumentError:
        return file_io.FileIO(uri, mode='r')

    with open(output_json, 'w') as outf:
      with _open_file_read_binary(uri) as f:
        image_bytes = f.read()
        image = Image.open(io.BytesIO(image_bytes)).convert('RGB')
        image = image.resize((299, 299), Image.BILINEAR)
        resized_image = io.BytesIO()
        image.save(resized_image, format='JPEG')
        encoded_image = base64.b64encode(resized_image.getvalue())
        row = json.dumps({'key': uri, 'image_bytes': {'b64': encoded_image}})
        outf.write(row)
        outf.write('\n') 
开发者ID:GoogleCloudPlatform,项目名称:cloudml-samples,代码行数:26,代码来源:pipeline.py

示例4: testErrorDuringRun

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def testErrorDuringRun(self):

    wrapper = TestDebugWrapperSession(self._sess, self._dump_root,
                                      self._observer)

    # No matrix size mismatch.
    self.assertAllClose(
        np.array([[11.0], [-1.0]]),
        wrapper.run(self._q, feed_dict={self._ph: np.array([[1.0], [2.0]])}))
    self.assertEqual(1, self._observer["on_run_end_count"])
    self.assertIsNone(self._observer["tf_error"])

    # Now there should be a matrix size mismatch error.
    wrapper.run(self._q, feed_dict={self._ph: np.array([[1.0], [2.0], [3.0]])})
    self.assertEqual(2, self._observer["on_run_end_count"])
    self.assertTrue(
        isinstance(self._observer["tf_error"], errors.InvalidArgumentError)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:19,代码来源:framework_test.py

示例5: test_sort_by_field_invalid_inputs

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def test_sort_by_field_invalid_inputs(self):
    corners = tf.constant([4 * [0.0], 4 * [0.5], 4 * [1.0], 4 * [2.0], 4 *
                           [3.0], 4 * [4.0]])
    misc = tf.constant([[.95, .9], [.5, .3]], tf.float32)
    weights = tf.constant([.1, .2], tf.float32)
    boxes = box_list.BoxList(corners)
    boxes.add_field('misc', misc)
    boxes.add_field('weights', weights)

    with self.test_session() as sess:
      with self.assertRaises(ValueError):
        box_list_ops.sort_by_field(boxes, 'area')

      with self.assertRaises(ValueError):
        box_list_ops.sort_by_field(boxes, 'misc')

      if ops._USE_C_API:
        with self.assertRaises(ValueError):
          box_list_ops.sort_by_field(boxes, 'weights')
      else:
        with self.assertRaisesWithPredicateMatch(errors.InvalidArgumentError,
                                                 'Incorrect field size'):
          sess.run(box_list_ops.sort_by_field(boxes, 'weights').get()) 
开发者ID:ambakick,项目名称:Person-Detection-and-Tracking,代码行数:25,代码来源:box_list_ops_test.py

示例6: testDieOnTargetSizeGreaterThanImageSize

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def testDieOnTargetSizeGreaterThanImageSize(self):
    image = np.dstack([[[5, 6],
                        [9, 0]],
                       [[4, 3],
                        [3, 5]]])
    with self.test_session():
      image_placeholder = tf.placeholder(tf.float32)
      padded_image = preprocess_utils.pad_to_bounding_box(
          image_placeholder, 0, 0, 2, 1, 255)
      with self.assertRaisesWithPredicateMatch(
          errors.InvalidArgumentError,
          'target_width must be >= width'):
        padded_image.eval(feed_dict={image_placeholder: image})
      padded_image = preprocess_utils.pad_to_bounding_box(
          image_placeholder, 0, 0, 1, 2, 255)
      with self.assertRaisesWithPredicateMatch(
          errors.InvalidArgumentError,
          'target_height must be >= height'):
        padded_image.eval(feed_dict={image_placeholder: image}) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:21,代码来源:preprocess_utils_test.py

示例7: testInteractivePlacePrunedGraph

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def testInteractivePlacePrunedGraph(self):
    sess = session.InteractiveSession()

    # Build a graph that has a bad op in it (no kernel).
    #
    # This test currently does not link in any GPU kernels,
    # which is why placing this is invalid.  If at some point
    # GPU kernels are added to this test, some other different
    # op / device combo should be chosen.
    with ops.device('/gpu:0'):
      a = constant_op.constant(1.0, shape=[1, 2])

    b = constant_op.constant(1.0, shape=[1, 2])

    # Only run the valid op, this should work.
    b.eval()

    with self.assertRaises(errors.InvalidArgumentError):
      a.eval()
    sess.close() 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:22,代码来源:session_test.py

示例8: testDefaultSessionPlacePrunedGraph

# 需要导入模块: from tensorflow.python.framework import errors [as 别名]
# 或者: from tensorflow.python.framework.errors import InvalidArgumentError [as 别名]
def testDefaultSessionPlacePrunedGraph(self):
    sess = session.Session()

    # Build a graph that has a bad op in it (no kernel).
    #
    # This test currently does not link in any GPU kernels,
    # which is why placing this is invalid.  If at some point
    # GPU kernels are added to this test, some other different
    # op / device combo should be chosen.
    with ops.device('/gpu:0'):
      _ = constant_op.constant(1.0, shape=[1, 2])

    b = constant_op.constant(1.0, shape=[1, 2])

    with self.assertRaises(errors.InvalidArgumentError):
      # Even though we don't run the bad op, we place the entire
      # graph, which should fail with a non-interactive session.
      sess.run(b)

    sess.close() 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:22,代码来源:session_test.py


注:本文中的tensorflow.python.framework.errors.InvalidArgumentError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。