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


Python ops._NodeDef函数代码示例

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


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

示例1: _WeMustGoDeeper

 def _WeMustGoDeeper(self, msg):
     with self.assertRaisesOpError(msg):
         node_def = ops._NodeDef("op_type", "name")
         node_def_orig = ops._NodeDef("op_type_orig", "orig")
         op_orig = ops.Operation(node_def_orig, ops.get_default_graph())
         op = ops.Operation(node_def, ops.get_default_graph(), original_op=op_orig)
         raise errors.UnauthenticatedError(node_def, op, "true_err")
开发者ID:peace195,项目名称:tensorflow,代码行数:7,代码来源:test_util_test.py

示例2: testInputsAndOutputs

  def testInputsAndOutputs(self):
    g = ops.Graph()
    op1 = ops.Operation(
        ops._NodeDef("noop", "myop1"), g, [], [dtypes.float32])
    self.assertEqual(1, len(op1.values()))
    float1_t, = op1.values()

    op2 = ops.Operation(ops._NodeDef("reop", "myop2"), g,
                        [], [dtypes.float32, dtypes.string])
    self.assertEqual(2, len(op2.values()))
    float2_t, label2_str_t = op2.values()

    # Note that we consume label2_str_t twice here.
    op3 = ops.Operation(ops._NodeDef("add", "myop3"), g,
                        [float1_t, label2_str_t, label2_str_t],
                        [dtypes.float32, dtypes.int32])
    self.assertEqual(2, len(op3.values()))

    self.assertEqual(1, len(float1_t._consumers))
    self.assertEqual(op3, float1_t._consumers[0])

    self.assertEqual(0, len(float2_t._consumers))

    self.assertEqual(2, len(label2_str_t._consumers))
    self.assertEqual(op3, label2_str_t._consumers[0])
    self.assertEqual(op3, label2_str_t._consumers[1])

    self.assertProtoEquals("""
    op:'add' name:'myop3'
    input:'myop1' input:'myop2:1' input:'myop2:1'
    """, op3.node_def)
开发者ID:4chin,项目名称:tensorflow,代码行数:31,代码来源:ops_test.py

示例3: testDeviceObject

 def testDeviceObject(self):
     op = ops.Operation(ops._NodeDef("noop", "myop"), ops.Graph(), [], [])
     op._set_device("/job:goo/device:GPU:0")
     self.assertProtoEquals("op:'noop' name:'myop' device:'/job:goo/device:GPU:0' ", op.node_def)
     op = ops.Operation(ops._NodeDef("noop", "op2"), ops.Graph(), [], [])
     op._set_device(pydev.Device(job="muu", device_type="CPU", device_index=0))
     self.assertProtoEquals("op:'noop' name:'op2' device:'/job:muu/device:CPU:0'", op.node_def)
开发者ID:negar-rostamzadeh,项目名称:tensorflow,代码行数:7,代码来源:ops_test.py

示例4: testInvalidNames

 def testInvalidNames(self):
   g = ops.Graph()
   with self.assertRaises(ValueError):
     ops.Operation(ops._NodeDef("op", ""), g)
   with self.assertRaises(ValueError):
     ops.Operation(ops._NodeDef("op", "_invalid"), g)
   with self.assertRaises(ValueError):
     ops.Operation(ops._NodeDef("op", "-invalid"), g)
   with self.assertRaises(ValueError):
     ops.Operation(ops._NodeDef("op", "/invalid"), g)
开发者ID:4chin,项目名称:tensorflow,代码行数:10,代码来源:ops_test.py

示例5: testReferenceInput

 def testReferenceInput(self):
     g = ops.Graph()
     op1 = ops.Operation(ops._NodeDef("noop", "op1"), g, [], [types.float32_ref, types.float32])
     self.assertProtoEquals("op:'noop' name:'op1'", op1.node_def)
     ref_t, nonref_t = op1.values()
     # NOTE(mrry): Must specify input_types to preserve ref-typed input.
     op2 = ops.Operation(
         ops._NodeDef("refop", "op2"), g, [ref_t, nonref_t], [], input_types=[types.float32_ref, types.float32]
     )
     self.assertProtoEquals("op:'refop' name:'op2' input:'op1' input:'op1:1'", op2.node_def)
     op3 = ops.Operation(ops._NodeDef("nonrefop", "op3"), g, [ref_t, nonref_t], [])
     self.assertProtoEquals("op:'nonrefop' name:'op3' input:'op1' input:'op1:1'", op3.node_def)
开发者ID:negar-rostamzadeh,项目名称:tensorflow,代码行数:12,代码来源:ops_test.py

示例6: testNoOutputs

    def testNoOutputs(self):
        g = ops.Graph()
        op1 = ops.Operation(ops._NodeDef("noop", "myop1"), g, [], [types.float32])
        float_t, = op1.values()
        op2 = ops.Operation(ops._NodeDef("reop", "myop2"), g, [float_t], [])
        self.assertEquals(0, len(op2.values()))
        self.assertEquals(1, len(op2.inputs))
        self.assertIs(float_t, op2.inputs[0])

        self.assertEquals(1, len(float_t._consumers))
        self.assertEquals(op2, float_t._consumers[0])

        self.assertProtoEquals("op:'noop' name:'myop1'", op1.node_def)
        self.assertProtoEquals("op:'reop' name:'myop2' input:'myop1'", op2.node_def)
开发者ID:negar-rostamzadeh,项目名称:tensorflow,代码行数:14,代码来源:ops_test.py

示例7: testShape

 def testShape(self):
   op = ops.Operation(ops._NodeDef("noop", "myop"), ops.Graph(),
                      [], [dtypes.float32])
   t = op.outputs[0]
   self.assertEqual(tensor_shape.unknown_shape(), t.get_shape())
   t.set_shape([1, 2, 3])
   self.assertEqual([1, 2, 3], t.get_shape())
开发者ID:4chin,项目名称:tensorflow,代码行数:7,代码来源:ops_test.py

示例8: testIterable

 def testIterable(self):
   op = ops.Operation(
       ops._NodeDef("noop", "myop"), ops.Graph(), [], [dtypes.float32])
   t = op.outputs[0]
   self.assertTrue(isinstance(t, ops.Tensor))
   with self.assertRaisesRegexp(TypeError, "not iterable"):
     for _ in t:
       pass
开发者ID:4chin,项目名称:tensorflow,代码行数:8,代码来源:ops_test.py

示例9: testRegisteredNode

 def testRegisteredNode(self):
   graph = ops.Graph()
   node = ops._NodeDef("a", "an_a")
   weight_params = ops.get_stats_for_node_def(graph, node, "weight_parameters")
   self.assertEqual(10, weight_params.value)
   flops = ops.get_stats_for_node_def(graph, node, "flops")
   self.assertEqual(20, flops.value)
   missing_stat = ops.get_stats_for_node_def(graph, node, "missing_stat")
   self.assertEqual(None, missing_stat.value)
开发者ID:4chin,项目名称:tensorflow,代码行数:9,代码来源:ops_test.py

示例10: testNoInputs

    def testNoInputs(self):
        op = ops.Operation(ops._NodeDef("noop", "myop"), ops.Graph(), [], [types.float32, types.string])
        self.assertEquals(2, len(op.values()))
        self.assertEquals(0, len(op.inputs))
        self.assertEquals("myop", op.name)

        float_t, label_str_t = op.values()
        self.assertEquals(types.float32, float_t.dtype)
        self.assertEquals(op, float_t.op)
        self.assertEquals(0, float_t._value_index)
        self.assertEquals(0, len(float_t._consumers))
        self.assertEquals("myop", float_t._as_node_def_input())

        self.assertEquals(types.string, label_str_t.dtype)
        self.assertEquals(op, label_str_t.op)
        self.assertEquals(1, label_str_t._value_index)
        self.assertEquals(0, len(label_str_t._consumers))
        self.assertEquals("myop:1", label_str_t._as_node_def_input())

        self.assertProtoEquals("op:'noop' name:'myop'", op.node_def)
开发者ID:negar-rostamzadeh,项目名称:tensorflow,代码行数:20,代码来源:ops_test.py

示例11: testNoArgs

 def testNoArgs(self):
   nodedef = ops._NodeDef("noop", "bar")
   self.assertProtoEquals("op: 'noop' name: 'bar'", nodedef)
开发者ID:4chin,项目名称:tensorflow,代码行数:3,代码来源:ops_test.py

示例12: testNoShapeFunction

 def testNoShapeFunction(self):
   g = ops.Graph()
   op = ops.Operation(ops._NodeDef("op", "an_op"), g,
                      output_types = [dtypes.float32])
   self.assertEqual(tensor_shape.unknown_shape(),
                    _apply_op(g, "an_op", [], [dtypes.float32]).get_shape())
开发者ID:4chin,项目名称:tensorflow,代码行数:6,代码来源:ops_test.py

示例13: testUnregisteredNode

 def testUnregisteredNode(self):
   graph = ops.Graph()
   node = ops._NodeDef("b", "a_b")
   weight_params = ops.get_stats_for_node_def(graph, node, "weight_params")
   self.assertEqual(None, weight_params.value)
开发者ID:4chin,项目名称:tensorflow,代码行数:5,代码来源:ops_test.py

示例14: testArgs

 def testArgs(self):
   nodedef = ops._NodeDef("foo", "bar", device="/device:baz:*")
   self.assertProtoEquals("op:'foo' name:'bar' device:'/device:baz:*'",
                          nodedef)
   nodedef = ops._NodeDef("foo", "bar", device=pydev.Device(job="j"))
   self.assertProtoEquals("op:'foo' name:'bar' device:'/job:j'", nodedef)
开发者ID:4chin,项目名称:tensorflow,代码行数:6,代码来源:ops_test.py


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