Skip to content

Conversation

marius190
Copy link

row_vector = matrix[1]
column_vector = matrix[:,2]
scalar = matrix[1, 2]

You cant acces third dimension (2) in a 2x2 matrix

row_vector = matrix[1] 
column_vector = matrix[:,2]
scalar = matrix[1, 2]

You cant acces third dimension (2) in a  2x2 matrix
@alaneuler
Copy link

alaneuler commented Jun 17, 2021

matrix is actually defined by yourself in previous cell, just code it bigger than 2

@nightcap1979
Copy link

marius190 is right, the following has to replace the current code:
row_vector = matrix[0]
column_vector = matrix[:,1]
scalar = matrix[0, 1]

@datasith
Copy link

Technically, @alaneuler is right. The description uses the term "dimensions" which in this context is interchangeable with "axes" or "rank" (see TensorFlow's documentation). Whether this was intentional or not, a solution could be to define a 2xn matrix with n>=3. I do agree that it would be more appropriate to choose indexes like those @nightcap1979 proposed such that it works for all tensors with 2 axes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants