Skip main navigation

Practical: regression in PyTorch

A link to a Colab notebook giving a worked example of a deep learning network performing a regession counting the number of flower heads in images
A scatter plot showing network prediction against annotated count, with a dotted line where the prediction equals the count. Most of the data lie on or near this line.
© The University of Nottingham
How do we adjust a CNN for use in a regression problem rather than classification?

In the linked Colab notebook we will take the image classifier we created in the previous practical, and convert it to a regression task that aims to count the number of flowers in each picture.

In the notebook we will cover the following:

  • setting up the dataset for use with our new regression problem
  • adjusting the “off-the-shelf” ResNet we used for the image classifier to count the number of flower heads rather than identify different species
  • checking the performance of the regression model using a simple plot.

Follow the link below and work through the Colab notebook step by step.

A simple regression problem in PyTorch

You may wish to open the link in a new browser tab so you can refer back here quickly.

Please leave any questions or comments below.

This article is from the free online

Deep Learning for Bioscientists

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now