model_utils.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Y8M 作者: mpekalski 项目源码 文件源码
def SampleSpacedFrames(model_input, num_frames, num_samples, header=2):
  batch_size = tf.shape(model_input)[0]

  sequence_float = tf.divide(tf.range(header, num_samples + header, dtype=tf.float32),  
                             tf.cast(header * 2 + num_samples, tf.float32) )
  sequence_mat = tf.reshape(sequence_float, [1, -1])

  frame_index = tf.cast( tf.matmul( tf.cast(num_frames, tf.float32), sequence_mat), tf.int32)
  frame_index = tf.minimum(frame_index, tf.cast(num_frames - 1, tf.int32))

  batch_index = tf.tile(tf.expand_dims(tf.range(batch_size), 1), [1, num_samples])
  index = tf.stack([batch_index, frame_index], 2)
  return tf.gather_nd(model_input, index)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号