nab*_*abu 0 python numpy python-2.7
我正在尝试在 python 中构建一个基本的数字分类器,我有一个 3923 * 65 数组。我的数组中的每一行都是一个图像,显示时是一个从 0 到 9 的数字。3923 * 64 是我的数组的实际大小,最后一列是图像的实际数字。我已经有一个用于整个 3923 * 65 的数组,还有一个用于 3923 * 64 部分的数组。全阵列:
fullImageArray = np.zeros((len(myImageList),65), dtype = np.float64)
fullImageArray = np.array(myImageList)
Run Code Online (Sandbox Code Playgroud)
数字数组:
fullPlotArray = np.zeros((len(myImageList),64), dtype = np.float64)
fullPlotArray = np.array(fullImageArray)
fullPlotArray.resize(len(myImageList),64)
Run Code Online (Sandbox Code Playgroud)
如何制作仅包含最后一列的数组?
您可以通过对数组进行切片来创建数据视图:
full_array = np.array(myImageList)
plot_array = full_array[:, :64] # First 64 columns of full_array
last_column = full_array[:, -1]
Run Code Online (Sandbox Code Playgroud)
结果将是与原始数组相同的数据的视图;没有创建副本。更改 的最后一列full_array与更改 相同last_column,因为它们指向内存中的相同数据。