Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use unlabeled images to improve image classification in Keras, first pretrain an image encoder with SimCLR: create two augmented views of each image, then train the encoder to recognize those views as a matching pair. Next, attach a classifier and train it with the labeled examples. Keras demonstrates this workflow on STL-10; its data counts and training settings are teaching-example choices, not minimum requirements or universal defaults.

What SimCLR does in a semi-supervised image-classification workflow

Semi-supervised learning uses a smaller labeled set alongside a larger pool of unlabeled images. SimCLR makes the unlabeled pool useful by learning visual representations before the classifier is trained. For each image, the pipeline creates two different augmented views. The encoder maps each view to a feature representation, and a nonlinear projection head maps those features into the space used for contrastive learning.

The objective encourages the two views of the same image to have similar projections, while distinguishing them from projections of other images in the batch. Keras’s example normalizes the projections, calculates temperature-scaled pairwise similarities, and applies a symmetrized cross-entropy loss with each matching view as the target. Labels do not participate in this contrastive objective.

The distinction between the encoder and projection head matters: the projection head is used to train the contrastive objective, while the encoder’s representation is what the downstream classifier uses. The original SimCLR paper by Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton summarizes its findings: “We show that (1) composition of data augmentations plays a critical role in defining effective predictive tasks, (2) introducing a learnable nonlinear transformation between the representation and the contrastive loss substantially improves the quality of the learned representations, and (3) contrastive learning benefits from larger batch sizes and more training steps compared to supervised learning.” The paper reports those findings under its own experimental protocols.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

How to follow the Keras STL-10 workflow

The Keras SimCLR example, created on April 24, 2021 and last modified on March 4, 2024, is a staged demonstration. It describes itself as “Contrastive pretraining with SimCLR for semi-supervised image classification on the STL-10 dataset.” The settings below belong to that example; they are not universal requirements.

Part of the example Configured setting or role
Unlabeled training examples 100,000 in the Keras STL-10 configuration
Labeled training examples 5,000 in the Keras STL-10 configuration
Example batch 525 images total: 500 unlabeled plus 25 labeled
Contrastive training duration 20 epochs in the example
Contrastive temperature 0.1 in the example’s similarity-based objective
Evaluation roles The labeled data supports the supervised baseline and linear probe; the test split is used for validation in the example

1. Prepare the labeled and unlabeled image streams

Separate the images with labels from those without them, and make sure both streams receive compatible image decoding and preprocessing. The Keras demonstration combines labeled and unlabeled examples in a training stream, but withholds their labels from the contrastive loss. Its 100,000-to-5,000 configuration is a concrete STL-10 setup, not a prescribed ratio for another dataset. If you have fewer labeled images or a different amount of unlabeled data, use the counts your dataset actually provides and evaluate the result on an appropriate held-out set.

2. Create two views of every pretraining image

For each image used in contrastive pretraining, independently apply the augmentation pipeline twice. Keras emphasizes random crops, color jitter, and horizontal flips. The two views should preserve the image’s class-relevant content while differing enough to make matching them useful. The tutorial uses stronger augmentation for contrastive learning and weaker augmentation for supervised classification, a choice intended to make the pretraining task informative without overfitting the small labeled subset during classification.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Augmentation is part of the learning problem, not cosmetic preprocessing. A crop or color change that removes a feature needed to identify the class may teach the wrong invariance for your task. Tune augmentation strength to the target domain and architecture rather than copying tutorial values; the Keras author warns that excessive strength can reduce downstream gains.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Train the encoder and projection head

Pass each augmented view through the encoder and then the projection head. Use the contrastive objective to bring matching views together and separate representations of other images in the batch. Keras’s example uses a compact convolutional encoder and a two-layer projection head. It configures Adam with a constant learning-rate schedule for the demonstration; these choices are not guaranteed to be optimal on another dataset.

During this phase, track a linear probe as a diagnostic: freeze the encoder, train a classifier on its features using labeled examples, and monitor validation behavior. A linear probe measures how readily a simple classifier can use the learned representation; it is not the same as the final fine-tuning result.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

4. Fine-tune for the target labels

After contrastive pretraining, attach a classification head to the pretrained encoder and train the model on labeled examples. Unlike a linear probe, fine-tuning updates the encoder as well as the classifier, allowing the representation to adapt to the target labels. Keep validation data out of training and compare against a supervised baseline trained from random initialization under a clearly stated, comparable evaluation protocol.

How to choose augmentations, batch size, and compute

Augmentations should match the image domain

Random crops, color jitter, and horizontal flips are the example’s central contrastive transformations, but not every transformation is valid for every task. For instance, whether a flip preserves meaning depends on the labels and domain. The tutorial also places custom preprocessing layers in the model pipeline and notes that batched augmentation can run on a GPU, which may help when CPU resources are constrained.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Batch size and training duration affect the trade-off

SimCLR compares views against other images in the batch, so batch size influences the contrastive training signal. The original paper reports benefits from larger batches and more training steps in its experiments; that does not mean the largest feasible batch is automatically best for a particular project. Larger batches and longer training also consume more compute. The Keras example’s batch of 525 and 20 epochs are reproducible reference settings for its demonstration, not a target to impose on other data.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Model capacity and optimization need tuning

A larger or deeper encoder, such as the ResNet-50 architecture often used in the literature, can improve representation quality but increases training time and memory use and may force a smaller batch. Keras identifies batch size, temperature, augmentation strength, learning-rate schedule, and optimizer as important choices. Its example uses temperature 0.1, Adam, and a constant schedule; cosine decay and SGD with momentum are alternatives discussed by the tutorial, but still require tuning.

A GPU is an option for accelerating suitable parts of the workflow, not a stated prerequisite. Hosted compute or a local machine may be used; the practical hardware requirement depends on image dimensions, encoder size, batch size, and training duration. Check the live Keras notebook and its dependency versions before reproducing it, because the example does not establish compatibility across current Keras and TensorFlow releases or provide a package-version matrix.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to evaluate whether pretraining helped

Use the same dataset split and evaluation method when comparing approaches. A linear probe evaluates frozen encoder features; fine-tuning updates the encoder using labels. Neither should be conflated with another protocol’s result, and validation accuracy alone does not establish that an approach will generalize to a different dataset.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

In its STL-10 example, Keras compares a randomly initialized supervised baseline with the pretraining-and-fine-tuning path and reports higher validation accuracy and lower validation loss for the latter. That is the tutorial’s reported comparison, not an independently reproduced result or a guarantee for other tasks.

Reported result Protocol and source
76.5% top-1 accuracy ImageNet linear evaluation of self-supervised representations reported by Chen, Kornblith, Norouzi, and Hinton in the 2020 original SimCLR paper
85.8% top-5 accuracy ImageNet result after fine-tuning with 1% of labels, reported by the same 2020 SimCLR paper
73.9% top-1 accuracy with 1% of labels; 77.5% with 10% of labels ImageNet ResNet-50 results after distillation reported by Chen, Kornblith, Swersky, Norouzi, and Hinton in the 2020 SimCLRv2 paper

These figures are not directly comparable: they come from different evaluation stages, label fractions, and protocols, and none is the Keras STL-10 tutorial result. The SimCLRv2 paper describes a larger three-stage approach: “The proposed semi-supervised learning algorithm can be summarized in three steps: unsupervised pretraining of a big ResNet model using SimCLRv2, supervised fine-tuning on a few labeled examples, and distillation with unlabeled examples for refining and transferring the task-specific knowledge.” Its distillation stage is an additional step beyond the Keras SimCLR workflow described above.

When SimCLR is a good fit—and when to compare alternatives

SimCLR is worth testing when you have a meaningful pool of unlabeled images from the same domain as your classification task and the compute to pretrain an encoder. Its practical value depends on label efficiency, the amount and quality of unlabeled data, whether its augmentations preserve task-relevant information, and the cost of model size, batch size, and training steps. No universal labeled-image threshold or guaranteed advantage over supervised training is established by the cited sources.

Compare alternatives using the same labeled split and evaluation protocol where possible. The Keras tutorial points to SimSiam, which avoids negatives, and to methods based on clustering or cross-correlation. Those methods use different learning objectives, so compare their data assumptions, augmentation suitability, compute needs, and downstream results rather than treating their headline metrics as interchangeable with SimCLR’s.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.