fix mnist dataset

This commit is contained in:
liyong 2021-11-18 16:34:45 +08:00
parent c0d35aa950
commit 3e1c668247
11 changed files with 1 additions and 12 deletions

View File

@ -192,9 +192,6 @@ Status MnistOp::ReadImageAndLabel(std::ifstream *image_reader, std::ifstream *la
TensorShape img_tensor_shape = TensorShape({kMnistImageRows, kMnistImageCols, 1});
for (int64_t j = 0; j != num_images; ++j) {
auto pixels = &images_buf[j * size];
for (int64_t m = 0; m < size; ++m) {
pixels[m] = (pixels[m] == 0) ? 0 : 255;
}
std::shared_ptr<Tensor> image;
RETURN_IF_NOT_OK(Tensor::CreateFromMemory(img_tensor_shape, data_schema_->Column(0).Type(),
reinterpret_cast<unsigned char *>(pixels), &image));

View File

@ -241,9 +241,6 @@ Status QMnistOp::ReadImageAndLabel(std::ifstream *image_reader, std::ifstream *l
TensorShape label_tensor_shape = TensorShape({kQMnistLabelLength});
for (int64_t data_index = 0; data_index != num_images; data_index++) {
auto image = &images_buf[data_index * image_size];
for (int64_t image_index = 0; image_index < image_size; image_index++) {
image[image_index] = (image[image_index] == 0) ? 0 : 255;
}
std::shared_ptr<Tensor> image_tensor;
RETURN_IF_NOT_OK(Tensor::CreateFromMemory(image_tensor_shape, data_schema_->Column(0).Type(),
reinterpret_cast<unsigned char *>(image), &image_tensor));

View File

@ -304,7 +304,7 @@ class TestSummary:
break
return tags
@pytest.mark.level0
@pytest.mark.level1
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_gpu_training

View File

@ -59,7 +59,6 @@ def load_emnist(path, usage, name):
image_file.read(16)
image = np.fromfile(image_file, dtype=np.uint8)
image = image.reshape(-1, 28, 28, 1)
image[image > 0] = 255 # Perform binarization to maintain consistency with our API
images.append(image)
with open(label_path[i], 'rb') as label_file:
label_file.read(8)

View File

@ -44,7 +44,6 @@ def load_fashion_mnist(path):
imgpath.read(16)
images = np.fromfile(imgpath, dtype=np.uint8)
images = images.reshape(-1, 28, 28, 1)
images[images > 0] = 255 # Perform binarization to maintain consistency with our API
return images, labels

View File

@ -44,7 +44,6 @@ def load_kmnist(path):
imgpath.read(16)
images = np.fromfile(imgpath, dtype=np.uint8)
images = images.reshape(-1, 28, 28, 1)
images[images > 0] = 255 # Perform binarization to maintain consistency with our API
return images, labels

View File

@ -39,7 +39,6 @@ def load_mnist(path):
imgpath.read(16)
images = np.fromfile(imgpath, dtype=np.uint8)
images = images.reshape(-1, 28, 28, 1)
images[images > 0] = 255 # Perform binarization to maintain consistency with our API
return images, labels

View File

@ -66,7 +66,6 @@ def load_qmnist(path, usage, compat=True):
image_file.read(16)
image = np.fromfile(image_file, dtype=np.uint8)
image = image.reshape(-1, 28, 28, 1)
image[image > 0] = 255 # Perform binarization to maintain consistency with our API
images.append(image)
with open(label_path[i], 'rb') as label_file:
label_file.read(12)