zoukankan      html  css  js  c++  java
  • mask-code-python

    tf.sqeeze:

    给定张量输入,此操作返回相同类型的张量,并删除所有尺寸为1的尺寸。 如果不想删除所有尺寸1尺寸,可以通过指定squeeze_dims来删除特定尺寸1尺寸。如果不想删除所有大小是1的维度,可以通过squeeze_dims指定。

    # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]

    shape(squeeze(t)) ==> [2, 3]

    Or, to remove specific size 1 dimensions

    # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]

    shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1]

     

     

     tf.gather_nd(params, indices, name=None) {#gather_nd} 用indices从张量params得到新张量

    cast(x, dtype, name=None) 将x的数据格式转化成dtype

    tuple中要求不能被改变,且(),list是[]

    tf.round函数用于将TensorFlow张量的值四舍五入为最接近的整数

    tf.stop_gradient() :阻挡节点BP的梯度

    tf.image.crop_and_resize(image, boxes, box_ind, crop_size, method=None, extrapolation_value=None, name=None)     The result is a 4-D tensor [num_boxes, crop_height, crop_width, depth

     

    return super(self.__class__, self).call(inputs, training=False)
    https://www.cnblogs.com/wjx1/p/5084980.html

    从运行结果上看,普通继承和super继承是一样的。但是其实它们的内部运行机制不一样,这一点在多重继承时体现得很明显。在super机制里可以保证公共父类仅被执行一次,至于执行的顺序,是按照mro进行的(E.__mro__)。

    tf.gather类似embedding lookup ,从tensor中返回指定index对应的

    isinstance函数可以对参数类型进行判断:

     对参数类型做检查,只允许整数和浮点数类型的参数。数据类型检查可以用内置函数isinstance实现:

    def my_abs(x):
        if not isinstance(x, (int, float)):
            raise TypeError('bad operand type')
        if x >= 0:
            return x
        else:
            return -x
    zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),第0个元组对应于所有参数的第0个元素,第1个元组对应于所有参数的第1个元素,依此类推,然后返回由这些tuples组成的list(列表)。若传入参数的长度不等,则返回list的长度和参数中长度最短的对象相同。
    zip([1,2,3,4],[5,6,7,8])会返回[(1, 5), (2, 6), (3, 7), (4, 8)]

    tf.round  向上取整

    # TF doesn't have an equivalent to np.repeate() so simulate it
    # using tf.tile() and tf.reshape.
    b1 = tf.reshape(tf.tile(tf.expand_dims(boxes1, 1),
    [1, 1, tf.shape(boxes2)[0]]), [-1, 4])
    https://blog.csdn.net/jasonzzj/article/details/60811035 -expanddims
    https://blog.csdn.net/loseinvain/article/details/78994615 --tile张量扩张


    control_dependencies(control_inputs)返回一个控制依赖的上下文管理器,使用with关键字可以让在这个上下文环境中的操作都在control_inputs 执行。

    with g.control_dependencies([a, b, c]):

    # `d` and `e` will only run after `a`, `b`, and `c` have executed.

      d = ...
      e = ...


    tf.control_dependencies和tf.identity同时使用:
    https://blog.csdn.net/winycg/article/details/78820032

    tf.reduce_sum:
    https://blog.csdn.net/lxg0807/article/details/74625861

    tf.booleen_mask:
    https://www.cnblogs.com/lyc-seu/p/7956231.html


    array([1, 2, 3, 1, 2, 3, 1, 2, 3])
    >>idx = np.where(a > 2)
    >>idx
    (array([2, 5, 8], dtype=int32),)


    n p.any:
    矩阵a和矩阵b中对应元素是否有一个相等,我们需要使用any..

    x1, x2 = horizontal_indicies[[0, -1]]
    y1, y2 = vertical_indicies[[0, -1]]
    # x2 and y2 should not be part of the box. Increment by 1.









     

  • 相关阅读:
    罗辑思维 140 认钱不认人(刚需是扯淡,一切都是稀缺,人生全是选择)——理性永远都是最珍贵的
    程序最多能new多少内存(2G内存里要放程序的5大区,HeapAlloc比new要快多了,而且超过2G的时候会告诉你)
    Qt中使用ActiveX(3篇)
    windows下的socket网络编程(入门级)
    网络数据包发送工具PacketSender中文源码
    avalon.js实现一个简易日历
    avalonJS入门(一)
    JS中的模块规范(CommonJS,AMD,CMD)
    程序员必看的书
    简单的语音聊天室
  • 原文地址:https://www.cnblogs.com/rosyYY/p/8734897.html
Copyright © 2011-2022 走看看