Navigation

    Gpushare.com

    • Register
    • Login
    • Search
    • Popular
    • Categories
    • Recent
    • Tags

    【闲谈】numpy array的axis问题

    技术分享📚有奖励
    1
    1
    318
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 173****7719
      173****7719 last edited by

      吐槽

      关于numpy array的axis,我总是记不住,或者是比较模糊,每次都得自己再造一个小array测试一下,确保不弄错。今天下定决心把这玩意给记住,自己弄了个联想记忆口诀,没有这个问题的就不要往下看啦,献丑了😌

      上图

      Capture2.JPG
      其实说白了就是记住这么个玩意,如果你已经记清楚了,也别往下看了🤡

      例子

      a = np.array([[1,1],[2,2]])
      # [1 1]
      # [2 2]
      print(np.mean(a,axis=0))
      #沿着axis0做平均
      [1.5, 1.5] 
       
      print(np.mean(a,axis=0))
      #沿着axis1做平均
      [1, 2]
      

      联想记忆

      献丑了。
      axis=0,从上往下,From Top to Bottom (TB)
      axis=1,从左往右,From Left to Right (LR)

      也就是
      0TB
      1LR

      联想记忆为
      不要(0)逃避(TB)
      要(1)礼让 (LR)

      又或者是
      清空 (0) 淘宝 (TB)
      买 (1) 卤肉 (LR)

      溜了溜了👣

      1 Reply Last reply Reply Quote 1
      • First post
        Last post