【问题标题】:tensorflow: sliding neighborhood masktensorflow:滑动邻域掩码
【发布时间】:2021-02-09 13:21:05
【问题描述】:

如何制作滑动邻域掩码,例如5个邻域掩码,假设掩码维度为[6, 6],则掩码应如下所示:

[[1 1 1 0 0 0]  #mask at pos 1
 [1 1 1 1 0 0]  #mask at pos 2
 [1 1 1 1 1 0]  #mask at pos 3
 [0 1 1 1 1 1]] #mask at pos 4

【问题讨论】:

    标签: tensorflow mask


    【解决方案1】:

    使用linalg.band_part():

    import tensorflow as tf
    input = tf.ones((6, 6), tf.int32)
    output = tf.linalg.band_part(input, 2, 2)
    

    【讨论】:

      猜你喜欢
      • 2019-11-15
      • 2018-08-05
      • 2019-01-16
      • 2019-04-12
      • 2011-06-08
      • 2014-12-08
      • 1970-01-01
      • 1970-01-01
      • 2017-03-19
      相关资源
      最近更新 更多