tensorflow reduce

    科技2025-05-15  6

    tf.reduce_any(input,dim) ----> input.any(dim) (pytorch)

    tensorflow

    >>> import tensorflow as tf >>> tf.__version__ '1.15.0' >>> a = tf.random.uniform((1,2,3)) >>> a = a>0 >>> a <tf.Tensor 'Greater_1:0' shape=(1, 2, 3) dtype=bool> >>> tf.reduce_any(a,axis=2) <tf.Tensor 'Any_1:0' shape=(1, 2) dtype=bool>

    pytorch

    >>> import torch >>> torch.__version__ '1.6.0' >>> a = torch.randn(1,2,3) >>> a tensor([[[ 0.0755, -0.8000, 2.5655], [-0.1672, -2.5226, 0.7619]]]) >>> a = a>0 >>> a tensor([[[ True, False, True], [False, False, True]]]) >>> a.any(1) tensor([[ True, False, True]])
    Processed: 0.010, SQL: 8