一次将阵列中的每一项分割 [英] divide every item in an array of arrays in one shot

查看:138
本文介绍了一次将阵列中的每一项分割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3X4X4的麻木形状,如图所示:

I have an numpy aray of shape 3X4X4 as shown:

[[[0 0 0 2]
  [0 0 0 0]
  [1 0 0 0]
  [0 0 0 0]]

 [[0 1 0 0]
  [0 0 0 0]
  [0 0 0 0]
  [0 1 1 0]]

 [[0 0 0 0]
  [0 1 1 0]
  [0 0 1 0]
  [0 0 0 0]]]

我想将数组中每个4 X4矩阵中的每个数字除以0.25. 然后,我想记录所有这些值. (因此,我将每个数组中的所有值除以.25,然后取该数字的对数) 输出应该是相同的3x4x4矩阵,只是更改了值. 有什么建议

I want to divide every number in each 4 X4 matrix inside my array by 0.25. Then I want to take a log of all those values. ( therefore Im dividing all the values in each array by .25 then taking the log of that number) The output should be the same 3x4x4 matrix, just the values are changed. Any suggestions

推荐答案

您可以轻松地做到:

numpy.log(yourNumpyArray / 0.25)

numpy会做正确的事(将每个元素除以0.25)

And numpy will do the right thing (divide each element by 0.25)

了解更多信息

这篇关于一次将阵列中的每一项分割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆