mnist

FashionMNIST Dataset not transforming to Tensor

FashionMNIST Dataset not transforming to Tensor Question: Trying to calculate the mean and standard deviation of the dataset to normalise it afterwards. Current Code: train_dataset = datasets.FashionMNIST(‘data’, train=True, download = True, transform=[transforms.ToTensor()]) test_dataset = datasets.FashionMNIST(‘data’, train=False, download = True, transform=[transforms.ToTensor()]) def calc_torch_mean_std(tens): mean = torch.mean(tens, dim=1) std = torch.sqrt(torch.mean((tens – mean[:, None]) ** 2, dim=1)) …

Total answers: 1

Bound label to Image

Bound label to Image Question: From the mnist dataset example I know that the dataset look something like this (60000,28,28) and the labels are (60000,). When, I print the first three examples of Mnist dataset and I print the first three labels of those which are: The images and labels are bounded. I want to …

Total answers: 1

How can I centre/detect the digits for MNIST Handwritten Digit Prediction?

How can I centre/detect the digits for MNIST Handwritten Digit Prediction? Question: I have a big issue with my CNN TensorFlow model, it seems to not be very good at its job, and I think it’s not the model’s fault but rather that the tensors being sent don’t have the digits centred. Here is a …

Total answers: 1

reshape not require to display mnist images?

reshape not require to display mnist images? Question: If I want to display one image from mnist dataset, I need to reshape it from (1,28,28) to (28,28) using the following code: import tensorflow as tf import matplotlib.pyplot as plt mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test …

Total answers: 1

Generating image from MNIST Data

Generating image from MNIST Data Question: I am quite new to python and pytorch. Please review my code below. I have tried everything I know but I am not able to create a MNIST data set image out of the matrix below. I expect the image should be 1. It would be great if someone …

Total answers: 1

Why are the MNIST images 1x28x28 tensors?

Why are the MNIST images 1x28x28 tensors? Question: I made the MNIST images which are 28×28 pixel images into tensors with dataset = MNIST(root=’data/’, train=True, transform=transforms.ToTensor()) and when I run img_tensor, label = dataset[0] print(img_tensor.shape, label) It says the shape is torch.Size([1, 28, 28]). Why is it a 1x28x28? What does the first dimension mean? …

Total answers: 3

why does cv2.imwrite method write a black square for a mnist test image dataset?

why does cv2.imwrite method write a black square for a mnist test image dataset? Question: I am trying to .imwrite one of the MNIST test images with openCV but it shows just a black square. I don’t get why!! import keras import numpy as np import mnist import tensorflow as tf from tensorflow.keras.models import Sequential …

Total answers: 2

python MNIST dataset "no attribute train_images"

python MNIST dataset "no attribute train_images" Question: I’m using python3.7 and trying to use MNIST train data images. Instead of using PyTorch, tf, kears framwork which help to use dataset easily, I tried using mnist module directly. I was following a tutorial for CNN, there was import mnist Then I tried “pip install python-mnist” (after …

Total answers: 3

Should I use softmax as output when using cross entropy loss in pytorch?

Should I use softmax as output when using cross entropy loss in pytorch? Question: I have a problem with classifying fully connected deep neural net with 2 hidden layers for MNIST dataset in pytorch. I want to use tanh as activations in both hidden layers, but in the end, I should use softmax. For the …

Total answers: 1

In TensorFlow, why a m*n matrix can add n * 1 matrix?

In TensorFlow, why a m*n matrix can add n * 1 matrix? Question: I am very new to python and TensorFlow, recent days I met a problem when I study “MNIST For ML Beginners”(https://www.tensorflow.org/get_started/mnist/beginners). In this tutorial, we use y = tf.nn.softmax(tf.matmul(X, W) + b) to get our outputs. My question is, for example, X …

Total answers: 1