18/01/2025
Teaching My AI the Nepali Way๐ค: Chaos, Momo, and Everything in Between
Training ML Model..?? Itโs like teaching a kid to separate momos ๐ฒ from samosas and chowmein ๐. Here's how I trained my โNepali kidโ AI with CIFAR-10 Dataset. Buckle up, itโs chaotic, like Kathmandu traffic.!! ๐ฆ
1. Data Prep: Tarkari Pasal Style ๐
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
Normalising data = washing tarkari before cooking. Clean data = better model! ๐ฅฆ
2. Building Dimaag ๐ง : Nepali Thali
def create_model():
model = models.Sequential([
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)),
layers.MaxPooling2D((2, 2)),
layers.Flatten(),
layers.Dense(64, activation='relu'),
layers.Dense(10, activation='softmax')
])
return model
Conv2D = rice ๐, MaxPooling = achar ๐ฅ, Dense = tarkari. Nepali AI thali!
3. Data Augmentation: Gym for AI ๐๏ธ
data_augmentation = tf.keras.Sequential([
layers.RandomFlip("horizontal"),
layers.RandomRotation(0.1),
layers.RandomZoom(0.1)
])
Augmentation = teaching AI chaos. Like finding roadblocks on the way to Thamel.
In a Hauba Way : AI learns to recognise a dai in daura suruwal or jeans. Nepali versatility at its best.!! ๐
4. Training: AIโs School Life ๐
for epoch in range(epochs):
for step, (x_batch_train, y_batch_train) in enumerate(datagen.flow(x_train, y_train)):
with tf.GradientTape() as tape:
logits = model(x_batch_train, training=True)
loss = loss_fn(y_batch_train, logits)
Training = school. Mistakes.?? Loads. Progress..?? Slow. Sometimes, it blanks out like a kid in class.๐
5. Nepali Twist: CutMix๐ธ
def cutmix(image, label):
lam = np.random.beta(1.0, 1.0)
rand_index = np.random.randint(0, x_train.shape[0])
image[bbx1:bbx2, bby1:bby2, :] = x_train[rand_index][bbx1:bbx2, bby1:bby2, :]
return image, lam * label + (1 - lam) * y_train[rand_index]
CutMix is chaos, like mixing momos and chowmein on one plate and asking AI to figure it out. ๐ค
6. Validation: Nosy Relatives Mode๐
val_logits = model(x_batch_val, training=False)
val_acc_metric.update_state(y_batch_val, val_logits)
Validation = report card time. If it flops here, it's like scoring 30 after claiming you studied all night. ๐
7. Testing: SEE Results ๐
test_loss, test_accuracy = model.evaluate(x_test, y_test)
print(f"Test accuracy: {test_accuracy:.4f}")
Testing AI is like an exam. It nails cats ๐ฑ and planes โ๏ธ, but calls a frog ๐ธ a dog ๐. Classic AI fail.! ๐ Anyone elseโs AI make these funny mistakes.?? Share your fails! ๐
Lessons Learnt
1. Clean Data: Like washing veggies for tarkari, donโt skip it! ๐ฅฆ
2. Embrace Chaos: Augmentation = handling KTM traffic jams. ๐ฆ
3. Prove It: Validation is like impressing nosy relatives, donโt fail! ๐๐
AI is chaos and creativity, like coding during load-shedding with chiya tough but rewarding.