源代码积少成多

    xiaoxiao2021-12-14  19

    ops

    convert_to_tensor

    name_scope

    def my_op(a, b, c, name=None): with tf.name_scope(name, "MyOp", [a, b, c]) as scope: a = tf.convert_to_tensor(a, name="a") b = tf.convert_to_tensor(b, name="b") c = tf.convert_to_tensor(c, name="c") # Define some computation that uses `a`, `b`, and `c`. return foo_op(..., name=scope)

    control_dependencies

    这个目前发现的是和control_flow_ops.Assert连用,可以看下面Assert的实例

    math_ops

    greater

    大于的显示true,支持broadcast

    array_ops

    size

    # 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]] size(t) ==> 12

    gen_array_ops

    identity

    Return a tensor with the same shape and contents as the input tensor or value

    gen_image_ops

    Decode a JPEG-encoded image to a uint8 tensor

    control_flow_ops

    Assert

    Asserts that the given condition is true

    # Ensure maximum element of x is smaller or equal to 1 assert_op = tf.Assert(tf.less_equal(tf.reduce_max(x), 1.), [x]) x = tf.with_dependencies([assert_op], x)
    转载请注明原文地址: https://ju.6miu.com/read-971720.html

    最新回复(0)