I test my network with the mnist dataset. Therefore the output of the model has shape 10.
How do I reshape the output? For example, if the output is label 3, is then the output [0 0 0 1 0 0 0 0 0 0], or [0 0 0 3 0 0 0 0 0 0] or completely different?
The thing is I don't want to use the dataloader. I use this method:
from mlxtend.data import loadlocal_mnist
X, y = loadlocal_mnist(
images_path='/home/wai043/data/mnist/train-images-idx3-ubyte',
labels_path='/home/wai043/data/mnist/train-labels-idx1-ubyte')
The output has to be [0, 0, 0, 1, 0, 0, 0, 0, 0, 0] if the label is 3. The y parameter you get from loadlocal_mnist has the direct label, so you need to "one-hot encode" y before your training.
You can use the following code to do the encoding
from mlxtend.preprocessing import one_hot
from mlxtend.data import loadlocal_mnist
X, y = loadlocal_mnist(images_path='/home/wai043/data/mnist/train-images-idx3-ubyte',
labels_path='/home/wai043/data/mnist/train-labels-idx1-ubyte')
y = one_hot(y)
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.