Num_uniq_both = sum(1 for value in mapping.values() if len(value) = 2) Num_uniq_6 = sum(1 for value in mapping.values() if len(value) = 1 and False in value) Num_uniq_3 = sum(1 for value in mapping.values() if len(value) = 1 and True in value) # Throw out images that match more than one label. # Determine the set of labels for each unique image: This is not a standard machine-learning procedure, but is included in the interest of following the paper. Plt.imshow(x_train_small, vmin=0, vmax=1)įrom section 3.3 Learning to Distinguish Digits of Farhi et al., filter the dataset to remove images that are labeled as belonging to both classes. X_test_small = tf.image.resize(x_test, (4,4)).numpy()Īgain, display the first training example-after resize: print(y_train) Resize the image down to 4x4: x_train_small = tf.image.resize(x_train, (4,4)).numpy() Show the first example: print(y_train)Īn image size of 28x28 is much too large for current quantum computers. Number of filtered training examples: 12049 Print("Number of filtered test examples:", len(x_test)) Print("Number of filtered training examples:", len(x_train)) X_test, y_test = filter_36(x_test, y_test) X_train, y_train = filter_36(x_train, y_train) At the same time convert the label, y, to boolean: True for 3 and False for 6. Number of original training examples: 60000įilter the dataset to keep just the 3s and 6s, remove the other classes. Print("Number of original training examples:", len(x_train)) Load the MNIST dataset distributed with Keras. Converts the Cirq circuits to TensorFlow Quantum circuits.Converts the binary images to Cirq circuits.Downscales the images so they fit can fit in a quantum computer.This section covers the data handling that: In this tutorial you will build a binary classifier to distinguish between the digits 3 and 6, following Farhi et al. 11:34:46.333443: E tensorflow/stream_executor/cuda/cuda_:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected Now import TensorFlow and the module dependencies: import tensorflow as tf Install TensorFlow Quantum: pip install tensorflow-quantum=0.7.2 # Update package resources to account for version changes. The performance of the quantum neural network on this classical data problem is compared with a classical neural network. This tutorial builds a quantum neural network (QNN) to classify a simplified version of MNIST, similar to the approach used in Farhi et al.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |