×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

LOG IN TO YOUR ACCOUNT

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR PASSWORD?

AAH, WAIT, I REMEMBER NOW!

CREATE AN ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • INFO

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

How to use Fashion-MNIST dataset in Google Cloud Machine Learning / AI Platform?

by Mirek Hermut / Monday, 21 October 2024 / Published in Artificial Intelligence, EITC/AI/GCML Google Cloud Machine Learning, Further steps in Machine Learning, Machine learning use case in fashion

Fashion-MNIST is a dataset of Zalando's article images, consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28×28 grayscale image, associated with a label from 10 classes. The dataset serves as a direct drop-in replacement for the original MNIST dataset for benchmarking machine learning algorithms, providing a more challenging alternative due to its complexity and variability in fashion-related images.

To practically use the Fashion-MNIST dataset in Google Cloud's AI Platform, one must follow several structured steps that encompass data preparation, model training, deployment, and evaluation. Each of these stages requires a comprehensive understanding of both the dataset and the Google Cloud environment.

Step 1: Setting Up Google Cloud Environment

Before utilizing the dataset, ensure that you have a Google Cloud account. Set up a new project in the Google Cloud Console. Enable billing for your project and activate the Cloud AI Platform API. This setup is important as it allows you to leverage Google's robust infrastructure for machine learning tasks.

1. Create a Google Cloud Project: Navigate to the Google Cloud Console and create a new project. Assign a unique name to your project for easy identification.
2. Enable APIs: Go to the API & Services dashboard and enable the Cloud AI Platform API. This API is essential for deploying machine learning models on Google Cloud.
3. Install Cloud SDK: Download and install the Google Cloud SDK on your local machine. This SDK provides the `gcloud` command-line tool, which is necessary for interacting with your Google Cloud resources.

Step 2: Preparing the Fashion-MNIST Dataset

The Fashion-MNIST dataset can be accessed from various sources, including the official GitHub repository. It is essential to preprocess the dataset to ensure it is in the correct format for training models on Google Cloud.

1. Download the Dataset: The dataset is available in multiple formats, including CSV and NumPy arrays. For TensorFlow users, it can be directly loaded using the `tensorflow.keras.datasets` module.

python
    from tensorflow.keras.datasets import fashion_mnist
    (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
    

2. Data Preprocessing: Normalize the pixel values of the images to the range [0, 1] by dividing by 255. This step is important for ensuring that the model converges efficiently during training.

python
    train_images = train_images / 255.0
    test_images = test_images / 255.0
    

3. Reshape and Augment Data: Depending on the model architecture, you may need to reshape the data. Additionally, consider data augmentation techniques such as rotation, zoom, and horizontal flip to enhance the model's robustness.

Step 3: Model Development

Develop a machine learning model suitable for the Fashion-MNIST dataset. Convolutional Neural Networks (CNNs) are a popular choice due to their efficacy in image classification tasks.

1. Define the Model Architecture: Use TensorFlow or PyTorch to define a CNN model. A typical architecture might include multiple convolutional layers followed by max-pooling layers, and a fully connected dense layer.

python
    model = tf.keras.Sequential([
        tf.keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
        tf.keras.layers.MaxPooling2D((2, 2)),
        tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
        tf.keras.layers.MaxPooling2D((2, 2)),
        tf.keras.layers.Flatten(),
        tf.keras.layers.Dense(64, activation='relu'),
        tf.keras.layers.Dense(10, activation='softmax')
    ])
    

2. Compile the Model: Choose an appropriate optimizer, loss function, and metrics. For multi-class classification, `sparse_categorical_crossentropy` is commonly used.

python
    model.compile(optimizer='adam',
                  loss='sparse_categorical_crossentropy',
                  metrics=['accuracy'])
    

3. Train the Model: Fit the model on the training data. Use validation data to monitor the model's performance and avoid overfitting.

{{EJS13}}

Step 4: Deploying the Model on Google Cloud AI Platform

Once the model is trained, the next step is to deploy it on Google Cloud AI Platform for scalable predictions. 1. Save the Model: Export the trained model to a format compatible with Google Cloud, such as TensorFlow SavedModel.
python
    model.save('fashion_mnist_model')
    

2. Upload the Model to Google Cloud Storage: Use the `gsutil` command-line tool to upload the model to a Google Cloud Storage bucket.

bash
    gsutil cp -r fashion_mnist_model gs://your-bucket-name/
    

3. Create a Model on AI Platform: In the Google Cloud Console, navigate to AI Platform > Models and create a new model. Specify the model name and region.

4. Deploy a Model Version: Create a new version of the model by specifying the Cloud Storage path of the SavedModel. Configure the machine type and scaling options based on your prediction needs.

5. Test the Deployment: Use the AI Platform's prediction service to test the deployed model. You can send HTTP requests with image data to the model endpoint and receive predictions.

{{EJS16}}

Step 5: Model Evaluation and Iteration

After deployment, it is important to evaluate the model's performance and iterate on the design to improve accuracy and efficiency. 1. Monitor Model Performance: Use Google Cloud's monitoring tools to track model performance metrics such as latency, throughput, and prediction accuracy. This data is invaluable for identifying bottlenecks and areas for improvement. 2. A/B Testing: Conduct A/B testing to compare different model versions. This approach helps in understanding the impact of changes and selecting the best-performing model. 3. Continuous Integration and Deployment (CI/CD): Implement CI/CD practices to automate the deployment of new model versions. This setup ensures that improvements are rapidly delivered to production. 4. Feedback Loop: Establish a feedback loop with end-users to gather insights on model predictions. Use this feedback to fine-tune the model and enhance its relevance to real-world applications. 5. Retraining with New Data: Regularly update the model with new data to maintain its accuracy over time. This practice is particularly important in the fashion industry, where trends and styles evolve rapidly. The Fashion-MNIST dataset provides a practical use case for deploying image classification models on Google Cloud's AI Platform. By following the outlined steps, one can effectively leverage Google's infrastructure to build, deploy, and maintain scalable machine learning models. This process not only enhances the model's accuracy and performance but also ensures its applicability to real-world scenarios in the fashion industry. Google frequently updates its AI Platform (as of 2024 evolved into the Vertex AI Platform). If you encounter any issues with these updates, you may also try the following code:
python
import google.auth
import google.auth.transport.requests
import requests
import json
from tensorflow.keras.datasets import fashion_mnist
import numpy as np

# Load and preprocess Fashion MNIST data
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
test_images = test_images / 255.0

# Add channel dimension to all test images
test_images = test_images.reshape(-1, 28, 28, 1)

# Prepare your model and project details
project_id = 'project_id'
model_name = 'modelname'
model_version = 'V1'
region = 'europe-west3'

# AI Platform prediction endpoint URL
url = f'https://{region}-ml.googleapis.com/v1/projects/{project_id}/models/{model_name}/versions/{model_version}:predict'

# Authenticate and get the auth token
credentials, _ = google.auth.default()
auth_req = google.auth.transport.requests.Request()
credentials.refresh(auth_req)
auth_token = credentials.token

# Set up headers for the request
headers = {
    'Authorization': f'Bearer {auth_token}',
    'Content-Type': 'application/json'
}

class_labels = [
    "T-shirt/top", "Trouser", "Pullover", "Dress", "Coat",
    "Sandal", "Shirt", "Sneaker", "Bag", "Ankle boot"
]

# Loop through the first 6 test images
for i in range(6):
    # Prepare the instance for prediction
    instance = test_images[i].tolist()
    
    # Make the request body
    data = json.dumps({"instances": [instance]})
    
    # Send the request
    response = requests.post(url, headers=headers, data=data)
    response_json = response.json()
    
    # Extract the predictions
    predicted_probs = response_json['predictions'][0]
    
    # Get the index of the highest probability
    predicted_index = np.argmax(predicted_probs)
    predicted_label = class_labels[predicted_index]
    predicted_probability = predicted_probs[predicted_index]
    
    # Print the result in a more readable format
    print(response_json)
    print(f"Image {i + 1}: Predicted class: {predicted_label} ({predicted_index}) with probability {predicted_probability:.10f}")

Other recent questions and answers regarding EITC/AI/GCML Google Cloud Machine Learning:

  • What are some common AI/ML algorithms to be used on the processed data?
  • How Keras models replace TensorFlow estimators?
  • How to configure specific Python environment with Jupyter notebook?
  • How to use TensorFlow Serving?
  • What is Classifier.export_saved_model and how to use it?
  • Why is regression frequently used as a predictor?
  • Are Lagrange multipliers and quadratic programming techniques relevant for machine learning?
  • Can more than one model be applied during the machine learning process?
  • Can Machine Learning adapt which algorithm to use depending on a scenario?
  • What is the simplest route to most basic didactic AI model training and deployment on Google AI Platform using a free tier/trial using a GUI console in a step-by-step manner for an absolute begginer with no programming background?

View more questions and answers in EITC/AI/GCML Google Cloud Machine Learning

More questions and answers:

  • Field: Artificial Intelligence
  • Programme: EITC/AI/GCML Google Cloud Machine Learning (go to the certification programme)
  • Lesson: Further steps in Machine Learning (go to related lesson)
  • Topic: Machine learning use case in fashion (go to related topic)
Tagged under: Artificial Intelligence, Convolutional Neural Networks, Data Preprocessing, Fashion MNIST, Google Cloud AI Platform, Model Deployment
Home » Artificial Intelligence / EITC/AI/GCML Google Cloud Machine Learning / Further steps in Machine Learning / Machine learning use case in fashion » How to use Fashion-MNIST dataset in Google Cloud Machine Learning / AI Platform?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (105)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Medium publ.)
  • About
  • Contact

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.

Eligibility for EITCA Academy 80% EITCI DSJC Subsidy support

80% of EITCA Academy fees subsidized in enrolment by

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on X
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF) in series of projects since 2007, currently governed by the European IT Certification Institute (EITCI) since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    EITCA Academy
    • EITCA Academy on social media
    EITCA Academy


    © 2008-2025  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP
    Chat with Support
    Chat with Support
    Questions, doubts, issues? We are here to help you!
    End chat
    Connecting...
    Do you have any questions?
    Do you have any questions?
    :
    :
    :
    Send
    Do you have any questions?
    :
    :
    Start Chat
    The chat session has ended. Thank you!
    Please rate the support you've received.
    Good Bad