Getting Started with Machine Learning in JavaScript: Beginner Quiz — Questions & Answers

This quiz contains 10 questions. Below is a complete reference of all questions, answer choices, and correct answers. You can use this section to review after taking the interactive quiz above.

  1. Question 1: Benefit of Browser-Based ML

    Which benefit of a JavaScript machine learning library allows models to run directly in the browser with interactive updates?

    • Real-time training in the browser
    • Requires server-only execution
    • Needs a native desktop app
    • Only works offline with batches
    • Disables GPU acceleration
    Show correct answer

    Correct answer: Real-time training in the browser

  2. Question 2: Including a Library in the Browser

    What HTML element would you use to include a JavaScript machine learning library from a CDN in a web page?

    • <script src='...'></script>
    • <link rel='ml' href='...'>
    • <style src='...'></style>
    • <import href='...'>
    • <module src='...'></module>
    Show correct answer

    Correct answer: <script src='...'></script>

  3. Question 3: Installing for Server-Side JS

    Which environment typically uses npm to install packages for server-side JavaScript machine learning tasks?

    • A server-side JavaScript runtime (using npm)
    • A CSS preprocessor
    • A SQL database
    • A browser extension manifest
    • A Java virtual machine
    Show correct answer

    Correct answer: A server-side JavaScript runtime (using npm)

  4. Question 4: Meaning of Sequential Model

    In a simple sequential model used for machine learning in JavaScript, what does 'sequential' describe?

    • A linear stack of layers
    • A cyclic graph network
    • A collection of unrelated functions
    • A database query plan
    • A sorted dataset
    Show correct answer

    Correct answer: A linear stack of layers

  5. Question 5: Dense Layer Input Shape

    If you create a dense layer to accept one numeric feature per example, what inputShape should you set?

    • [1]
    • [1, 1, 1]
    • [0]
    • [2]
    • ['1']
    Show correct answer

    Correct answer: [1]

  6. Question 6: Optimizer Used in Example

    Which optimizer is used in the compilation step of the example to train the model predicting y from x?

    • sgd
    • adam
    • rmsprop
    • random-step
    • gradient-ascent
    Show correct answer

    Correct answer: sgd

  7. Question 7: Loss for Regression

    For a simple regression task predicting numbers (for example, y = 2x - 1), which loss function is appropriate in the example?

    • meanSquaredError
    • categoricalCrossentropy
    • binaryAccuracy
    • hinge
    • meanSquareError
    Show correct answer

    Correct answer: meanSquaredError

  8. Question 8: Tensor Shape for Inputs

    When preparing five input values [0, 1, 2, 3, 4] as a 2D tensor with one feature each, what shape should you use?

    • [5, 1]
    • [1, 5]
    • [5]
    • [1, 1, 5]
    • [0, 5]
    Show correct answer

    Correct answer: [5, 1]

  9. Question 9: Evaluate Linear Function

    Using the function y = 2x - 1 from the example, what is the correct output when x = 3?

    • 5
    • 7
    • 6
    • -5
    • 2
    Show correct answer

    Correct answer: 5

  10. Question 10: Browser Acceleration

    Which browser technology is commonly used by JavaScript machine learning libraries to speed up computations using the GPU?

    • WebGL
    • WebSQL
    • WebMail
    • Service Workers
    • WebRTC
    Show correct answer

    Correct answer: WebGL