Jump to content

Recommended Posts

Posted


Na documentação está:
>>> np.trace(np.eye(3))
3.0
>>> a = np.arange(8).reshape((2,2,2))
>>> np.trace(a)
array([6, 8])


Contudo na perspectiva que procurei e pesquisei obtive:
array([

         [ [0, 1],

           [2, 3]

         ],

          [

              [4, 5],

              [6, 7]

           ]

])

 

Ele divide em matriz a[0]: [0, 1], [2, 3]

e matriz em matriz a[1]: [4, 5], [6, 7]

presumo eu, o resultado pensando assim será:

np.trace(a[0]) =  3
np.trace(a[1]) = 11

--
Qual a vossa perspectiva?

Posted
Em 26/03/2024 às 21:41, Rui Carlos disse:

Suspeito do slicing que é feito ao "cubo" é diferente do que indicaste, e que resulta em [[0,4],[2,6]] e [[1,5],[3,7]].

Sim assim bate certo Rui Carlos, mto obriagdo pela resposta

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.