• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python execute.execute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tensorflow.python.eager.execute.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testExecuteListTypeListShapeAttr

 def testExecuteListTypeListShapeAttr(self):
   execute.execute(
       'Barrier',
       num_outputs=1,
       inputs=[],
       attrs=('component_types', [dtypes.float64.as_datatype_enum], 'shapes',
              [[1, 2]], 'capacity', -1, 'container', '', 'shared_name', ''))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例2: testExecuteListFloatAttrBadValue

 def testExecuteListFloatAttrBadValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         'Bucketize',
         num_outputs=1,
         inputs=[tensor.Tensor([3.0, 5.0, 7.0])],
         attrs=('T', dtypes.float32.as_datatype_enum, 'boundaries', 4.0))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例3: testExecuteListIntAttrBadValue

 def testExecuteListIntAttrBadValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         'Squeeze',
         num_outputs=1,
         inputs=[tensor.Tensor([[[3.0]]])],
         attrs=('T', dtypes.float32.as_datatype_enum, 'squeeze_dims', 0))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例4: testExecuteShapeAttr

 def testExecuteShapeAttr(self):
   execute.execute(
       'VarHandleOp',
       num_outputs=1,
       inputs=[],
       attrs=('shape', [1, 2], 'dtype', dtypes.int32.as_datatype_enum,
              'container', '', 'shared_name', ''))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例5: testExecuteUnknownAttr

 def testExecuteUnknownAttr(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         'Identity',
         num_outputs=1,
         inputs=[tensor.Tensor(3)],
         attrs=('T', dtypes.int32.as_datatype_enum, 'unknown_attr', 'blah'))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例6: testExecuteListTypeAttrBadListValue

 def testExecuteListTypeAttrBadListValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         b'Barrier',
         num_outputs=1,
         inputs=[],
         attrs=('component_types', '1', 'shapes', [[1, 2]], 'capacity', -1,
                'container', '', 'shared_name', ''))
开发者ID:1000sprites,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例7: testExecuteListIntAttrBadListValue

 def testExecuteListIntAttrBadListValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         b'Squeeze',
         num_outputs=1,
         inputs=[constant_op.constant([[[3.0]]])],
         attrs=('T', dtypes.float32.as_datatype_enum, 'squeeze_dims',
                ['0', '2']))
开发者ID:1000sprites,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例8: testExecuteListFloatAttrBadListValue

 def testExecuteListFloatAttrBadListValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         b'Bucketize',
         num_outputs=1,
         inputs=[constant_op.constant([3.0, 5.0, 7.0])],
         attrs=('T', dtypes.float32.as_datatype_enum, 'boundaries',
                ['4.0', '6.0']))
开发者ID:1000sprites,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例9: testExecuteListShapeAttrBadListValue

 def testExecuteListShapeAttrBadListValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         'Barrier',
         num_outputs=1,
         inputs=[],
         attrs=('component_types', [dtypes.float64.as_datatype_enum], 'shapes',
                [1], 'capacity', -1, 'container', '', 'shared_name', ''))
开发者ID:chdinh,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例10: testExecuteListStringAttrBadListValue

 def testExecuteListStringAttrBadListValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         'TensorSummary',
         num_outputs=1,
         inputs=[tensor.Tensor(3.0)],
         attrs=('T', dtypes.float32.as_datatype_enum, 'description', '',
                'labels', [3], 'display_name', 'test'))
开发者ID:chdinh,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例11: testExecuteListStringAttr

 def testExecuteListStringAttr(self):
   execute.execute(
       'TensorSummary',
       num_outputs=1,
       inputs=[tensor.Tensor(3.0)],
       attrs=('T', dtypes.float32.as_datatype_enum, 'description',
              'tensor_summary', 'labels', ['3',
                                           'summary'], 'display_name', 'test'))
开发者ID:chdinh,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例12: testExecuteShapeAttrBadValue

 def testExecuteShapeAttrBadValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     execute.execute(
         'VarHandleOp',
         num_outputs=1,
         inputs=[],
         attrs=('shape', 1, 'dtype', dtypes.int32.as_datatype_enum,
                'container', '', 'shared_name', ''))
开发者ID:chdinh,项目名称:tensorflow,代码行数:8,代码来源:core_test.py


示例13: testOperationWithNoInputsRunsOnDevice

  def testOperationWithNoInputsRunsOnDevice(self):
    if not context.context().num_gpus():
      self.skipTest('No GPUs found')
    shape = tensor.Tensor([], dtype=dtypes.int32)

    # x: Run the "TruncatedNormal" op CPU and copy result to GPU.
    x = truncated_normal(shape).as_gpu_tensor()
    # y: Explicitly run the "TruncatedNormal" op on GPU.
    with context.device('gpu:0'):
      y = truncated_normal(shape)
    # Add would fail if x and y were not on the same device.
    execute.execute(
        'Add', 1, inputs=[x, y], attrs=('T', x.dtype.as_datatype_enum))
开发者ID:chdinh,项目名称:tensorflow,代码行数:13,代码来源:core_test.py


示例14: xla_launch_eager_fallback

def xla_launch_eager_fallback(constants, args, resources, Tresults, function, name=None, ctx=None):
  r"""This is the slowpath function for Eager mode.
  This is for function xla_launch
  """
  _ctx = ctx if ctx else _context.context()
  if not isinstance(resources, (list, tuple)):
    raise TypeError(
        "Expected list for 'resources' argument to "
        "'xla_launch' Op, not %r." % resources)
  _attr_Nresources = len(resources)
  if not isinstance(Tresults, (list, tuple)):
    raise TypeError(
        "Expected list for 'Tresults' argument to "
        "'xla_launch' Op, not %r." % Tresults)
  Tresults = [_execute.make_type(_t, "Tresults") for _t in Tresults]
  _attr_Tconstants, constants = _execute.convert_to_mixed_eager_tensors(constants, _ctx)
  _attr_Targs, args = _execute.convert_to_mixed_eager_tensors(args, _ctx)
  resources = _ops.convert_n_to_tensor(resources, _dtypes.resource)
  _inputs_flat = list(constants) + list(args) + list(resources)
  _attrs = ("Tconstants", _attr_Tconstants, "Targs", _attr_Targs,
  "Nresources", _attr_Nresources, "Tresults", Tresults, "function", function)
  _result = _execute.execute(b"XlaLaunch", len(Tresults), inputs=_inputs_flat,
                             attrs=_attrs, ctx=_ctx, name=name)
  _execute.record_gradient(
      "XlaLaunch", _inputs_flat, _attrs, _result, name)
  return _result
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:26,代码来源:xla_ops.py


示例15: _capture_by_value

 def _capture_by_value(
     self,
     op_type,
     inputs,
     dtypes,  # pylint: disable=redefined-outer-name
     input_types=None,
     name=None,
     attrs=None,
     op_def=None,
     compute_shapes=True,
     compute_device=True):
   # When capturing by value, do the read outside
   reverse_captures = dict((v, k) for k, v in self.captures.items())
   uncaptured_inputs = [reverse_captures.get(t, t) for t in inputs]
   with ops.init_scope():
     if context.executing_eagerly():
       attr_list = ("dtype", int(attrs["dtype"].type))
       value, = execute.execute(
           compat.as_bytes(op_type), 1, uncaptured_inputs, attr_list,
           context.context())
     else:
       op = ops.get_default_graph().create_op(
           op_type, uncaptured_inputs, dtypes, input_types, name, attrs,
           op_def, compute_shapes, compute_device)
       value = op.outputs[0]
   captured_value = self.capture(value)
   return captured_value.op
开发者ID:kylin9872,项目名称:tensorflow,代码行数:27,代码来源:func_graph.py


示例16: testExecuteIntAttr

 def testExecuteIntAttr(self):
   total = execute.execute(
       b'AddN',
       num_outputs=1,
       inputs=[constant_op.constant(3), constant_op.constant(4)],
       attrs=('T', dtypes.int32.as_datatype_enum, 'N', 2))[0]
   self.assertEqual(7, total.numpy())
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例17: testExecuteIntAttr

 def testExecuteIntAttr(self):
   total = execute.execute(
       'AddN',
       num_outputs=1,
       inputs=[tensor.Tensor(3), tensor.Tensor(4)],
       attrs=('T', dtypes.int32.as_datatype_enum, 'N', 2))[0]
   self.assertEqual(7, total.numpy())
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例18: testExecuteFloatAttrBadValue

 def testExecuteFloatAttrBadValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     _ = execute.execute(
         'ApproximateEqual',
         num_outputs=1,
         inputs=[tensor.Tensor(3.0), tensor.Tensor(2.9)],
         attrs=('tolerance', '0.3', 'T', dtypes.float32.as_datatype_enum))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例19: testExecuteFloatAttr

 def testExecuteFloatAttr(self):
   almost_equal = execute.execute(
       'ApproximateEqual',
       num_outputs=1,
       inputs=[tensor.Tensor(3.0), tensor.Tensor(2.9)],
       attrs=('tolerance', 0.3, 'T', dtypes.float32.as_datatype_enum))[0]
   self.assertTrue(almost_equal.numpy())
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py


示例20: testExecuteStringAttrBadValue

 def testExecuteStringAttrBadValue(self):
   with self.assertRaises(errors.InvalidArgumentError):
     _ = execute.execute(
         'CheckNumerics',
         num_outputs=1,
         inputs=[tensor.Tensor(3.)],
         attrs=('message', 1, 'T', dtypes.float32.as_datatype_enum))
开发者ID:chdinh,项目名称:tensorflow,代码行数:7,代码来源:core_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python function.defun函数代码示例发布时间:2022-05-27
下一篇:
Python def_function.function函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap