简体   繁体   中英

What does matrix[x] for different x indicate?

While using the MNIST datasetfrom kaggle,i have noticed that all the tutorials use mnist[x] for different values of x to retrieve different pictures.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

mnist=pd.read_csv(r"(dir of dataset)").values
img=mnist[1]
img.shape=(28,28)
plt.imshow(img)
plt.show()

My doubt is what mnist[1] retrieves,also i have noticed that mnist[-1] also works,so that is why i am confused.

In Python, a matrix is just an array of array. Notice the second "array" I mentioned here could be another "matrix".

So your "matrix[x]" simply means the (x+1)th element of your object.


In case of the matrix for a dataset, mostly the first dimension of the matrix would be the sample id.

So your "matrix[x]" means the argument array of the (x+1)th sample.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM