SlideShare a Scribd company logo
1 of 4
Please, write an addition to the following python code that will generate a 2d weight space
contour plot:
import matplotlib.pyplot as plt
import numpy as np
from sklearn.model_selection import train_test_split
def sigmoid(sop):
return 1.0/(1 + np.exp(-sop))
def error(predicted, target):
return np.mean(np.power(predicted - target, 2))
def error_predicted_deriv(predicted, target):
return 2 * (predicted - target)
def activation_sop_deriv(sop):
return sigmoid(sop) * (1.0 - sigmoid(sop))
def update_weights(weights, grads, learning_rate):
return weights - learning_rate * grads
# Generate data
mean = np.array([-0.4, -0.8])
mean1 = np.array([0.4, 0.8])
cov = np.array([[0.84, 0], [0, 0.036]])
x1 = np.random.multivariate_normal(mean, cov, 50)
x2 = np.random.multivariate_normal(mean1, cov, 50)
data = np.concatenate((x1, x2))
# Generate desired output
d = np.concatenate((np.zeros(50), np.ones(50)))
# Split data into train and test sets
X_train, X_test, d_train, d_test = train_test_split(
data, d, test_size=0.2, random_state=0
)
# Assign labels to the data points
labels = np.zeros(100)
labels[:50] = -1 # class 1
labels[50:] = 1 # class 2
plt.scatter(data[labels==-1, 0], data[labels==-1, 1], c='r', label='Class 1')
plt.scatter(data[labels==1, 0], data[labels==1, 1], c='b', label='Class 2')
plt.legend()
plt.show()
# Initialize weights
weights = np.random.rand(2)
# Train the network
max_iterations = 10
learning_rate = 1.5
MSE = []
train_pred = []
test_pred = []
for iteration in range(max_iterations):
# Forward Pass
sop = np.dot(X_train, weights)
predicted = sigmoid(sop)
err = error(predicted, d_train)
# Backward Pass
grad_predicted = error_predicted_deriv(predicted, d_train)
grad_sop = activation_sop_deriv(sop)
grad_weights = np.dot(X_train.T, grad_predicted * grad_sop)
# Update weights
weights = update_weights(weights, grad_weights, learning_rate)
print("Updated weights:", weights)
err = error(predicted, d_train)
MSE.append(np.mean(err))
if iteration % 100 == 0:
print(f"Iteration {iteration}: Error = {err}")
log_MSE = np.log10(MSE)
print("Final weights:", weights)
plt.plot(range(10), log_MSE, label='Log MSE (dB)')
plt.xlabel('Iteration')
plt.ylabel('Log MSE (dB)')
plt.legend()
plt.show()
Please- write an addition to the following python code that will gener.docx

More Related Content

Similar to Please- write an addition to the following python code that will gener.docx

Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdfsimenehanmut
 
Using the code below- I need help with the following 3 things- 1) Writ.pdf
Using the code below- I need help with the following 3 things- 1) Writ.pdfUsing the code below- I need help with the following 3 things- 1) Writ.pdf
Using the code below- I need help with the following 3 things- 1) Writ.pdfacteleshoppe
 
From Tensorflow Graph to Tensorflow Eager
From Tensorflow Graph to Tensorflow EagerFrom Tensorflow Graph to Tensorflow Eager
From Tensorflow Graph to Tensorflow EagerGuy Hadash
 
How to use SVM for data classification
How to use SVM for data classificationHow to use SVM for data classification
How to use SVM for data classificationYiwei Chen
 
Assignment 6.1.pdf
Assignment 6.1.pdfAssignment 6.1.pdf
Assignment 6.1.pdfdash41
 
NUMPY [Autosaved] .pptx
NUMPY [Autosaved]                    .pptxNUMPY [Autosaved]                    .pptx
NUMPY [Autosaved] .pptxcoolmanbalu123
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
 
[PR12] PR-036 Learning to Remember Rare Events
[PR12] PR-036 Learning to Remember Rare Events[PR12] PR-036 Learning to Remember Rare Events
[PR12] PR-036 Learning to Remember Rare EventsTaegyun Jeon
 
Python Unit Test
Python Unit TestPython Unit Test
Python Unit TestDavid Xie
 
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...South Tyrol Free Software Conference
 
Hybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskitHybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskitVijayananda Mohire
 
simple linear regression
simple linear regressionsimple linear regression
simple linear regressionAkhilesh Joshi
 

Similar to Please- write an addition to the following python code that will gener.docx (20)

Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
 
Using the code below- I need help with the following 3 things- 1) Writ.pdf
Using the code below- I need help with the following 3 things- 1) Writ.pdfUsing the code below- I need help with the following 3 things- 1) Writ.pdf
Using the code below- I need help with the following 3 things- 1) Writ.pdf
 
Ml all programs
Ml all programsMl all programs
Ml all programs
 
Python programing
Python programingPython programing
Python programing
 
From Tensorflow Graph to Tensorflow Eager
From Tensorflow Graph to Tensorflow EagerFrom Tensorflow Graph to Tensorflow Eager
From Tensorflow Graph to Tensorflow Eager
 
How to use SVM for data classification
How to use SVM for data classificationHow to use SVM for data classification
How to use SVM for data classification
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
 
Assignment 6.1.pdf
Assignment 6.1.pdfAssignment 6.1.pdf
Assignment 6.1.pdf
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
NUMPY [Autosaved] .pptx
NUMPY [Autosaved]                    .pptxNUMPY [Autosaved]                    .pptx
NUMPY [Autosaved] .pptx
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
[PR12] PR-036 Learning to Remember Rare Events
[PR12] PR-036 Learning to Remember Rare Events[PR12] PR-036 Learning to Remember Rare Events
[PR12] PR-036 Learning to Remember Rare Events
 
Python Unit Test
Python Unit TestPython Unit Test
Python Unit Test
 
Python basic
Python basicPython basic
Python basic
 
Neural networks using tensor flow in amazon deep learning server
Neural networks using tensor flow in amazon deep learning serverNeural networks using tensor flow in amazon deep learning server
Neural networks using tensor flow in amazon deep learning server
 
Unit test
Unit testUnit test
Unit test
 
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...
 
Hybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskitHybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskit
 
NUMPY
NUMPY NUMPY
NUMPY
 
simple linear regression
simple linear regressionsimple linear regression
simple linear regression
 

More from madalynbb3ja

Please type out the Rational models like the example -incident---descr.docx
Please type out the Rational models like the example -incident---descr.docxPlease type out the Rational models like the example -incident---descr.docx
Please type out the Rational models like the example -incident---descr.docxmadalynbb3ja
 
Please solve this ASAP 2- Barnard's Star is one of the nearest stars t.docx
Please solve this ASAP 2- Barnard's Star is one of the nearest stars t.docxPlease solve this ASAP 2- Barnard's Star is one of the nearest stars t.docx
Please solve this ASAP 2- Barnard's Star is one of the nearest stars t.docxmadalynbb3ja
 
please show step by step- asks for multile years Switzertand has long.docx
please show step by step- asks for multile years Switzertand has long.docxplease show step by step- asks for multile years Switzertand has long.docx
please show step by step- asks for multile years Switzertand has long.docxmadalynbb3ja
 
please provide your personal reflection on what you learned doing this.docx
please provide your personal reflection on what you learned doing this.docxplease provide your personal reflection on what you learned doing this.docx
please provide your personal reflection on what you learned doing this.docxmadalynbb3ja
 
please in C++ Many documents use a specific format for a person's name.docx
please in C++ Many documents use a specific format for a person's name.docxplease in C++ Many documents use a specific format for a person's name.docx
please in C++ Many documents use a specific format for a person's name.docxmadalynbb3ja
 
Please help! Invasive species can be particularly troublesome- particu.docx
Please help! Invasive species can be particularly troublesome- particu.docxPlease help! Invasive species can be particularly troublesome- particu.docx
Please help! Invasive species can be particularly troublesome- particu.docxmadalynbb3ja
 
please help me with these two thank you- What of the following describ.docx
please help me with these two thank you- What of the following describ.docxplease help me with these two thank you- What of the following describ.docx
please help me with these two thank you- What of the following describ.docxmadalynbb3ja
 
Please give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docx
Please give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docxPlease give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docx
Please give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docxmadalynbb3ja
 
please help me Hamid Enterprise Trial Balance for the Month of Julu 2.docx
please help me  Hamid Enterprise Trial Balance for the Month of Julu 2.docxplease help me  Hamid Enterprise Trial Balance for the Month of Julu 2.docx
please help me Hamid Enterprise Trial Balance for the Month of Julu 2.docxmadalynbb3ja
 
Please help fill in the missing code below in order for it run correct.docx
Please help fill in the missing code below in order for it run correct.docxPlease help fill in the missing code below in order for it run correct.docx
Please help fill in the missing code below in order for it run correct.docxmadalynbb3ja
 
please help The master production schedule (MPS) is the source of all.docx
please help  The master production schedule (MPS) is the source of all.docxplease help  The master production schedule (MPS) is the source of all.docx
please help The master production schedule (MPS) is the source of all.docxmadalynbb3ja
 
please help raw a graph showing the change in membrane potential as a.docx
please help  raw a graph showing the change in membrane potential as a.docxplease help  raw a graph showing the change in membrane potential as a.docx
please help raw a graph showing the change in membrane potential as a.docxmadalynbb3ja
 
Please create a journal entry & adjusting entries 12) Only part of th.docx
Please create a journal entry & adjusting entries  12) Only part of th.docxPlease create a journal entry & adjusting entries  12) Only part of th.docx
Please create a journal entry & adjusting entries 12) Only part of th.docxmadalynbb3ja
 
Please Answer this 4- List three of the advantages of reflecting teles.docx
Please Answer this 4- List three of the advantages of reflecting teles.docxPlease Answer this 4- List three of the advantages of reflecting teles.docx
Please Answer this 4- List three of the advantages of reflecting teles.docxmadalynbb3ja
 
please answer these two question- Thank you- will for sure like- Aprre.docx
please answer these two question- Thank you- will for sure like- Aprre.docxplease answer these two question- Thank you- will for sure like- Aprre.docx
please answer these two question- Thank you- will for sure like- Aprre.docxmadalynbb3ja
 
Please answer all 6 of the following ICD 10 codes for the following di.docx
Please answer all 6 of the following ICD 10 codes for the following di.docxPlease answer all 6 of the following ICD 10 codes for the following di.docx
Please answer all 6 of the following ICD 10 codes for the following di.docxmadalynbb3ja
 
Please answer All Requlred Information -The following information app.docx
Please answer All  Requlred Information -The following information app.docxPlease answer All  Requlred Information -The following information app.docx
Please answer All Requlred Information -The following information app.docxmadalynbb3ja
 
Plants with genotype BbRryy are intercrossed- Calculate the following.docx
Plants with genotype BbRryy are intercrossed- Calculate the following.docxPlants with genotype BbRryy are intercrossed- Calculate the following.docx
Plants with genotype BbRryy are intercrossed- Calculate the following.docxmadalynbb3ja
 
pl answer (a) When can liquid metals be used as heat transfer media- -.docx
pl answer (a) When can liquid metals be used as heat transfer media- -.docxpl answer (a) When can liquid metals be used as heat transfer media- -.docx
pl answer (a) When can liquid metals be used as heat transfer media- -.docxmadalynbb3ja
 
Physiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docx
Physiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docxPhysiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docx
Physiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docxmadalynbb3ja
 

More from madalynbb3ja (20)

Please type out the Rational models like the example -incident---descr.docx
Please type out the Rational models like the example -incident---descr.docxPlease type out the Rational models like the example -incident---descr.docx
Please type out the Rational models like the example -incident---descr.docx
 
Please solve this ASAP 2- Barnard's Star is one of the nearest stars t.docx
Please solve this ASAP 2- Barnard's Star is one of the nearest stars t.docxPlease solve this ASAP 2- Barnard's Star is one of the nearest stars t.docx
Please solve this ASAP 2- Barnard's Star is one of the nearest stars t.docx
 
please show step by step- asks for multile years Switzertand has long.docx
please show step by step- asks for multile years Switzertand has long.docxplease show step by step- asks for multile years Switzertand has long.docx
please show step by step- asks for multile years Switzertand has long.docx
 
please provide your personal reflection on what you learned doing this.docx
please provide your personal reflection on what you learned doing this.docxplease provide your personal reflection on what you learned doing this.docx
please provide your personal reflection on what you learned doing this.docx
 
please in C++ Many documents use a specific format for a person's name.docx
please in C++ Many documents use a specific format for a person's name.docxplease in C++ Many documents use a specific format for a person's name.docx
please in C++ Many documents use a specific format for a person's name.docx
 
Please help! Invasive species can be particularly troublesome- particu.docx
Please help! Invasive species can be particularly troublesome- particu.docxPlease help! Invasive species can be particularly troublesome- particu.docx
Please help! Invasive species can be particularly troublesome- particu.docx
 
please help me with these two thank you- What of the following describ.docx
please help me with these two thank you- What of the following describ.docxplease help me with these two thank you- What of the following describ.docx
please help me with these two thank you- What of the following describ.docx
 
Please give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docx
Please give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docxPlease give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docx
Please give an explaination fir those quesions! 2 3 4 5 1- Aman with r.docx
 
please help me Hamid Enterprise Trial Balance for the Month of Julu 2.docx
please help me  Hamid Enterprise Trial Balance for the Month of Julu 2.docxplease help me  Hamid Enterprise Trial Balance for the Month of Julu 2.docx
please help me Hamid Enterprise Trial Balance for the Month of Julu 2.docx
 
Please help fill in the missing code below in order for it run correct.docx
Please help fill in the missing code below in order for it run correct.docxPlease help fill in the missing code below in order for it run correct.docx
Please help fill in the missing code below in order for it run correct.docx
 
please help The master production schedule (MPS) is the source of all.docx
please help  The master production schedule (MPS) is the source of all.docxplease help  The master production schedule (MPS) is the source of all.docx
please help The master production schedule (MPS) is the source of all.docx
 
please help raw a graph showing the change in membrane potential as a.docx
please help  raw a graph showing the change in membrane potential as a.docxplease help  raw a graph showing the change in membrane potential as a.docx
please help raw a graph showing the change in membrane potential as a.docx
 
Please create a journal entry & adjusting entries 12) Only part of th.docx
Please create a journal entry & adjusting entries  12) Only part of th.docxPlease create a journal entry & adjusting entries  12) Only part of th.docx
Please create a journal entry & adjusting entries 12) Only part of th.docx
 
Please Answer this 4- List three of the advantages of reflecting teles.docx
Please Answer this 4- List three of the advantages of reflecting teles.docxPlease Answer this 4- List three of the advantages of reflecting teles.docx
Please Answer this 4- List three of the advantages of reflecting teles.docx
 
please answer these two question- Thank you- will for sure like- Aprre.docx
please answer these two question- Thank you- will for sure like- Aprre.docxplease answer these two question- Thank you- will for sure like- Aprre.docx
please answer these two question- Thank you- will for sure like- Aprre.docx
 
Please answer all 6 of the following ICD 10 codes for the following di.docx
Please answer all 6 of the following ICD 10 codes for the following di.docxPlease answer all 6 of the following ICD 10 codes for the following di.docx
Please answer all 6 of the following ICD 10 codes for the following di.docx
 
Please answer All Requlred Information -The following information app.docx
Please answer All  Requlred Information -The following information app.docxPlease answer All  Requlred Information -The following information app.docx
Please answer All Requlred Information -The following information app.docx
 
Plants with genotype BbRryy are intercrossed- Calculate the following.docx
Plants with genotype BbRryy are intercrossed- Calculate the following.docxPlants with genotype BbRryy are intercrossed- Calculate the following.docx
Plants with genotype BbRryy are intercrossed- Calculate the following.docx
 
pl answer (a) When can liquid metals be used as heat transfer media- -.docx
pl answer (a) When can liquid metals be used as heat transfer media- -.docxpl answer (a) When can liquid metals be used as heat transfer media- -.docx
pl answer (a) When can liquid metals be used as heat transfer media- -.docx
 
Physiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docx
Physiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docxPhysiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docx
Physiological symptoms of Jimsonweed include all EXCEPT Photophobia -&.docx
 

Recently uploaded

Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 

Recently uploaded (20)

Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 

Please- write an addition to the following python code that will gener.docx

  • 1. Please, write an addition to the following python code that will generate a 2d weight space contour plot: import matplotlib.pyplot as plt import numpy as np from sklearn.model_selection import train_test_split def sigmoid(sop): return 1.0/(1 + np.exp(-sop)) def error(predicted, target): return np.mean(np.power(predicted - target, 2)) def error_predicted_deriv(predicted, target): return 2 * (predicted - target) def activation_sop_deriv(sop): return sigmoid(sop) * (1.0 - sigmoid(sop)) def update_weights(weights, grads, learning_rate): return weights - learning_rate * grads # Generate data mean = np.array([-0.4, -0.8]) mean1 = np.array([0.4, 0.8]) cov = np.array([[0.84, 0], [0, 0.036]]) x1 = np.random.multivariate_normal(mean, cov, 50) x2 = np.random.multivariate_normal(mean1, cov, 50) data = np.concatenate((x1, x2)) # Generate desired output d = np.concatenate((np.zeros(50), np.ones(50)))
  • 2. # Split data into train and test sets X_train, X_test, d_train, d_test = train_test_split( data, d, test_size=0.2, random_state=0 ) # Assign labels to the data points labels = np.zeros(100) labels[:50] = -1 # class 1 labels[50:] = 1 # class 2 plt.scatter(data[labels==-1, 0], data[labels==-1, 1], c='r', label='Class 1') plt.scatter(data[labels==1, 0], data[labels==1, 1], c='b', label='Class 2') plt.legend() plt.show() # Initialize weights weights = np.random.rand(2) # Train the network max_iterations = 10 learning_rate = 1.5 MSE = [] train_pred = [] test_pred = [] for iteration in range(max_iterations): # Forward Pass sop = np.dot(X_train, weights)
  • 3. predicted = sigmoid(sop) err = error(predicted, d_train) # Backward Pass grad_predicted = error_predicted_deriv(predicted, d_train) grad_sop = activation_sop_deriv(sop) grad_weights = np.dot(X_train.T, grad_predicted * grad_sop) # Update weights weights = update_weights(weights, grad_weights, learning_rate) print("Updated weights:", weights) err = error(predicted, d_train) MSE.append(np.mean(err)) if iteration % 100 == 0: print(f"Iteration {iteration}: Error = {err}") log_MSE = np.log10(MSE) print("Final weights:", weights) plt.plot(range(10), log_MSE, label='Log MSE (dB)') plt.xlabel('Iteration') plt.ylabel('Log MSE (dB)') plt.legend() plt.show()