[英]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.在使用 kaggle 的 MNIST 数据集时,我注意到所有教程都使用 mnist[x] 来获取不同的 x 值来检索不同的图片。
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.我的疑问是
mnist[1]
检索了什么,我也注意到mnist[-1]
也有效,所以这就是我感到困惑的原因。
In Python, a matrix is just an array of array.在 Python 中,矩阵只是数组的数组。 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.因此,您的“矩阵 [x]”仅表示对象的第 (x+1) 个元素。
In case of the matrix for a dataset, mostly the first dimension of the matrix would be the sample id.在数据集矩阵的情况下,矩阵的第一维通常是样本 id。
So your "matrix[x]" means the argument array of the (x+1)th sample.所以你的“矩阵 [x]”是指第 (x+1) 个样本的参数数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.