Challenge: 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:
- Initialize parameters:
- Create the array of weights using
np.random.uniform()with values in the range [β1,1). - Create a single bias value using the same uniform distribution.
- Both should be initialized in the neuron's constructor (
__init__).
- Create the array of weights using
- 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.
- Inside the
- Apply the activation function:
- Use the provided
sigmoid()function to compute the neuronβs output frominput_sum_with_bias. - Store the result in the variable
outputand return it.
- Use the provided
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single
Ask AI
Ask AI
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?
Awesome!
Completion rate improved to 4
Challenge: 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:
- Initialize parameters:
- Create the array of weights using
np.random.uniform()with values in the range [β1,1). - Create a single bias value using the same uniform distribution.
- Both should be initialized in the neuron's constructor (
__init__).
- Create the array of weights using
- 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.
- Inside the
- Apply the activation function:
- Use the provided
sigmoid()function to compute the neuronβs output frominput_sum_with_bias. - Store the result in the variable
outputand return it.
- Use the provided
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single