mask-code-python

tf.sqeeze:html

給定張量輸入,此操做返回相同類型的張量,並刪除全部尺寸爲1的尺寸。 若是不想刪除全部尺寸1尺寸,能夠經過指定squeeze_dims來刪除特定尺寸1尺寸。若是不想刪除全部大小是1的維度,能夠經過squeeze_dims指定。python

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

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

Or, to remove specific size 1 dimensionsui

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

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

 

 

 tf.gather_nd(params, indices, name=None) {#gather_nd} 用indices從張量params獲得新張量code

cast(x, dtype, name=None) 將x的數據格式轉化成dtypehtm

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.




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..

d = ... e = ...
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.
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息