Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Creating a Neuron | Neural Network from Scratch
Introduction to Neural Networks

bookChallenge: Creating a Neuron

Task

Swipe to start coding

Your task is to implement the basic structure of a single neuron by completing the missing parts of the code below.

Follow these steps carefully:

  1. Initialize parameters:
    • Create the array of weights using np.random.uniform() with values in the range [βˆ’1,1)[-1, 1).
    • Create a single bias value using the same uniform distribution.
    • Both should be initialized in the neuron's constructor (__init__).
  2. Compute the neuron's input:
    • Inside the activate() method, calculate the weighted sum of the inputs using the dot product:
      np.dot(inputs, self.weights)
      
    • Add the bias to this sum and store the result in the variable input_sum_with_bias.
  3. Apply the activation function:
    • Use the provided sigmoid() function to compute the neuron’s output from input_sum_with_bias.
    • Store the result in the variable output and return it.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 2
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me an example?

close

Awesome!

Completion rate improved to 4

bookChallenge: Creating a Neuron

Swipe to show menu

Task

Swipe to start coding

Your task is to implement the basic structure of a single neuron by completing the missing parts of the code below.

Follow these steps carefully:

  1. Initialize parameters:
    • Create the array of weights using np.random.uniform() with values in the range [βˆ’1,1)[-1, 1).
    • Create a single bias value using the same uniform distribution.
    • Both should be initialized in the neuron's constructor (__init__).
  2. Compute the neuron's input:
    • Inside the activate() method, calculate the weighted sum of the inputs using the dot product:
      np.dot(inputs, self.weights)
      
    • Add the bias to this sum and store the result in the variable input_sum_with_bias.
  3. Apply the activation function:
    • Use the provided sigmoid() function to compute the neuron’s output from input_sum_with_bias.
    • Store the result in the variable output and return it.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 2
single

single

some-alt