Skip to content

Machine_Learning

Tedros Tsegay edited this page Mar 16, 2023 · 2 revisions

This is a Markdown code for the machine-learning step-by-steep

First, go to AWS -> EC2 -> Instance -> Launch Instance. Put Name for your instance and choose ubuntu for the server and t2.large for instance type and choose Key pair. Put 10 GIB for storage, then click on the launch instance. Now you will have an instance, and you can activate it with a Public IPv4 number using the terminal to have Jupiter notebook on the server.

Here are the steps taken for the code in the Jupiter notebook.

First import the necessary Python packages and modules for building an image classifier using TensorFlow.

Next, retrieve the cassava plant disease dataset and split it into training, validation, and tes. t dataset.

Here's a step-by-step explanation of what the code is doing: **Second cell **

  1. The tfds_name variable is set to 'cassava', which is the name of the dataset to be loaded from TFDS.
  2. The tfds.load() function is called to load the cassava dataset and its splits into ds_train, ds_validation, and ds_test. The split argument specifies which splits to load, while with_info=True tells the function also to load the dataset metadata (e.g., number of classes, image size). The as_supervised=True argument loads the dataset in a format that can be used for supervised learning.
  3. The ds_info variable stores the metadata of the loaded dataset, such as the number of classes and the image size.
  4. The TFLITE_NAME_PREFIX variable is set to tfds_name, which will be used later to name the exported TensorFlow Lite model.

**Third cell **

  1. The label_names variable is set to the names of the labels in the dataset, which is retrieved from the metadata ds_info
  2. Two ImageClassifierDataLoader objects are created to load the training and validation datasets. The ImageClassifierDataLoader takes the dataset, its cardinality (number of samples), and the label names.
  3. The model_name variable is set to 'mobilenet_v3_large_100_224', specifying the pre-trained model's name for transfer learning.
  4. The map_model_name dictionary maps the model_name to its corresponding URL on TensorFlow Hub where the pre-trained weights can be downloaded. For example, if model_name is 'mobilenet_v3_large_100_224', the URL for the pre-trained weights is 'https://tfhub.dev/google/imagenet/mobilenet_v3_large_100_224/feature_vector/5'.
  5. The model_handle variable is set to the value of the map_model_name dictionary for the model_name. This will be used later to load the pre-trained weights for transfer learning.

**fourth cell **

Clone this wiki locally