Oct-16-2019, 11:18 AM
I suspect you've used a dataset which is similar to this one.
As far as I understand, pixel inversion is transformation when black colors become white and vice verse?! If so, the following code can help you:
As far as I understand, pixel inversion is transformation when black colors become white and vice verse?! If so, the following code can help you:
import pandas as pd import numpy as np import matplotlib.pyplot as plt data=pd.read_csv("https://raw.githubusercontent.com/sjwhitworth/golearn/master/examples/datasets/mnist_train.csv") data.values[:, 1:] = np.abs(data.values[:, 1:] - 255) # color inversion x=data.values[-1, 1:] # plot latest row in the dataset plt.imshow(x.reshape(28, 28), cmap='gray') plt.show()