Python代写|COMP-377 Lab Assignment #4 – Use CNNs in image classification problems

这是一个加拿大的Python CNN图像分类作业代写

In this exercise you will implement a CNN model for digit classification using tensorflow and MNIST dataset. The site https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist/load_data will help you to figure out how to fetch the data using a special tensorflow function. Overall, use convolution layers and pooling layers that are eventually followed by a densely connected output layer. Here is the architecture of the network:

Do not use one-hot encoding of the target.

Compile the model using the loss function SparseCategoricalCrossentropy (You need to use this loss function since you must not use one-hot encoding of the target). Train the model using the top 60 rows out of 60000 rows of the training data (present in x_train; see below how to obtain the training data in x_train). Test the model using top 10 rows out of 10000 rows of test data (present in x_test; see below how to obtain the test data in x_test). Evaluate the accuracy of the model. Compare the result with those of the SVM model used in lab2.

Note: If you go down the webpage https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist/load_data   you will see an example usage of the method keras.datasets.mnist.load_data. It returns four objects of type ndarray. Those four objects are x_train, x_test, y_train, y_test. Another file that could be of help is in a News item under the string 8.1.using.built-in.dataset.of.sklearn.digit.images.for.tensorflow.Conv2D.model.ipynb

It also has an associated video in the same News item under the string 8.1.using.built-in.dataset.of.sklearn.digit.images.for.tensorflow.Conv2D.model

Here is another tensorflow website that shows the current way of creating a CNN architecture:

https://www.tensorflow.org/tutorials/images/classification

(5 marks)

In this exercise you will build a CNN model for photo classification using tensorflow and CIFAR-10 dataset. The site  https://www.tensorflow.org/api_docs/python/tf/keras/datasets/cifar10/load_data  will help you to figure out how to fetch the data using a special tensorflow function. Use the same technique as in Exercise 1 above to create the CNN architecture. Train the model using the top 50 rows out of 50000 rows of the training data (present in x_train; see below how to obtain the training data in x_train). Test the model using top 10 rows out of 10000 rows of test data (present in x_test; see below how to obtain the test data in x_test). Evaluate the accuracy of the model.

Note: If you go down the webpage https://www.tensorflow.org/api_docs/python/tf/keras/datasets/cifar10/load_data   you will see an example usage of the method keras.datasets.cifar10.load_data. It returns four objects of type ndarray. Those four objects are x_train, x_test, y_train, y_test. Another file that could be of help is in a News item under the string 8.1.using.built-in.dataset.of.sklearn.digit.images.for.tensorflow.Conv2D.model.ipynb

It also has an associated video in the same News item under the string 8.1.using.built-in.dataset.of.sklearn.digit.images.for.tensorflow.Conv2D.model.

Here is another tensorflow website that shows the current way of creating a CNN architecture:

https://www.tensorflow.org/tutorials/images/classification

(5 marks)

Evaluation:

Correct design and implementation of requirements

Code explanation if asked

At least a single-line comment for each functionality

Total