🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Project 10: Custom Price Scaler Layer

ML Engineer

Builds on these lessons

Current Task

Objective

Subclassing layers.Layer and implementing call() lets you define custom computation Keras doesn't already provide as a built-in layer.

Task: write a PriceScaler custom layer that multiplies its input by a factor, and print the scaled result.

index.py
import tensorflow as tf from tensorflow.keras import layers class PriceScaler(layers.Layer): def __init__(self, factor): super().__init__() self.factor = factor def call(self, inputs): return inputs * self.factor scaler = PriceScaler(1000.0) print(scaler(tf.constant([250.0, 340.0])).numpy())

* Hint: Correct characters turn green, incorrect ones turn red.

Live Preview
🖼️

Verify your code to see the preview