بتل کد Battle Codeدارد باز می‌شود…

جواب «Step 1: The Lesson Notes» چالش 1 از جلسه‌ی 58

سؤال

قدم اول: پایگاه دانش آماده است. در تابع show_lessons به جای pass یک خط بنویس که عنوان و منبع هر درس را به شکل title (source) چاپ کند. خروجی ده خط است: 9 lessons، overfitting (session 48)، validation (session 49)، relu (session 43)، softmax (session 44)، mini-batch (session 45)، decision tree (sessions 50-51)، convolution (session 53)، embedding (session 55)، attention (session 57).

راهنما

داخل حلقه lesson یک دیکشنری است: lesson["title"] و lesson["source"]. پرانتزها را در یک f-string بگذار.

یک جواب درست

import numpy as np

LESSONS = [
    {"title": "overfitting", "source": "session 48",
     "text": "overfitting is when a model memorises the training data and does badly on new test data",
     "answer": "Overfitting means the model memorised its training examples and fails on new ones."},
    {"title": "validation", "source": "session 49",
     "text": "a validation set is data the model never trains on so we can check it fairly",
     "answer": "A validation set is kept apart from training so you can measure the model fairly."},
    {"title": "relu", "source": "session 43",
     "text": "relu is an activation that keeps positive numbers and turns negative numbers into zero",
     "answer": "ReLU keeps a positive number and turns a negative one into 0, like max(0, x)."},
    {"title": "softmax", "source": "session 44",
     "text": "softmax turns a list of scores into probabilities that are positive and add up to one",
     "answer": "Softmax turns scores into probabilities that add up to 1."},
    {"title": "mini-batch", "source": "session 45",
     "text": "a mini batch is a small group of training examples used for one step of gradient descent",
     "answer": "A mini-batch is a small group of examples used for one gradient descent step."},
    {"title": "decision tree", "source": "sessions 50-51",
     "text": "a decision tree asks yes or no questions about the features and splits the data at every node",
     "answer": "A decision tree asks one yes/no question per node and splits the data until a leaf answers."},
    {"title": "convolution", "source": "session 53",
     "text": "convolution slides a small filter over the image and adds up each patch times the filter to find edges",
     "answer": "Convolution slides a small filter across the picture and adds up patch * filter at every spot."},
    {"title": "embedding", "source": "session 55",
     "text": "a word embedding is a vector of numbers for a word so that similar words get close vectors",
     "answer": "A word embedding is a vector for a word; similar words point in similar directions."},
    {"title": "attention", "source": "session 57",
     "text": "attention lets every word look at the other words of the sentence with a query a key and a value",
     "answer": "In attention every word scores the others (query times key), softmax gives weights, and it mixes their values."},
]


def show_lessons():
    print(len(LESSONS), "lessons")
    for lesson in LESSONS:
        print(f"{lesson['title']} ({lesson['source']})")


show_lessons()

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن