SlideShare a Scribd company logo
1 of 5
Please help fill in the missing code below in order for it run correctly. Areas that are
needed/missing are in highlighted in bold .
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
#1) Generate the synthetic data using the following Python code snippet.
# Generate synthetic data
N = 100
# Zeros form a Gaussian centered at (-1, -1)
x_zeros = np.random.multivariate_normal(mean=np.array((-1, -1)), cov=.1*np.eye(2),
size=(N//2,))
y_zeros = np.zeros((N//2,))
# Ones form a Gaussian centered at (1, 1)
x_ones = np.random.multivariate_normal(mean=np.array((1, 1)), cov=.1*np.eye(2),
size=(N//2,))
y_ones = np.ones((N//2,))
x_np = np.vstack([x_zeros, x_ones])
y_np = np.concatenate([y_zeros, y_ones])
# Plot x_zeros and x_ones on the same graph
plt.scatter(x_zeros[:,0], x_zeros[:,1], label='class 0')
plt.scatter(x_ones[:,0], x_ones[:,1], label='class 1')
plt.legend()
plt.show()
#3) Generate a TensorFlow graph.
with tf.name_scope("placeholders"):
x = tf.constant(x_np, dtype=tf.float32)
y = tf.constant(y_np, dtype=tf.float32)
with tf.name_scope("weights"):
W = tf.Variable(tf.random.normal((2, 1)))
b = tf.Variable(tf.random.normal((1,)))
with tf.name_scope("prediction"):
y_logit = tf.squeeze(tf.matmul(x, W) + b)
# the sigmoid gives the class probability of 1
y_one_prob = tf.sigmoid(y_logit)
# Rounding P(y=1) will give the correct prediction.
y_pred = tf.round(y_one_prob)
with tf.name_scope("loss"):
# Compute the cross-entropy term for each datapoint
entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y)
# Sum all contributions
l = tf.reduce_sum(entropy)
with tf.name_scope("optim"):
train_op = tf.compat.v1.train.AdamOptimizer(.01).minimize(l)
with tf.name_scope("summaries"):
tf.compat.v1.summary.scalar("loss", l)
merged = tf.compat.v1.summary.merge_all()
train_writer = tf.compat.v1.summary.FileWriter('logistic-train',
tf.compat.v1.get_default_graph())
#4) Train the model, get the weights, and make predictions.
#5) Plot the predicted outputs on top of the data.
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
#1) Generate the synthetic data using the following Python code snippet.
# Generate synthetic data
N = 100
# Zeros form a Gaussian centered at (-1, -1)
x_zeros = np.random.multivariate_normal(mean=np.array((-1, -1)),
cov=.1*np.eye(2), size=(N//2,))
y_zeros = np.zeros((N//2,))
# Ones form a Gaussian centered at (1, 1)
x_ones = np.random.multivariate_normal(mean=np.array((1, 1)),
cov=.1*np.eye(2), size=(N//2,))
y_ones = np.ones((N//2,))
x_np = np.vstack([x_zeros, x_ones])
y_np = np.concatenate([y_zeros, y_ones])
# Plot x_zeros and x_ones on the same graph
plt.scatter(x_zeros[:,0], x_zeros[:,1], label='class 0')
plt.scatter(x_ones[:,0], x_ones[:,1], label='class 1')
plt.legend()
plt.show()
#3) Generate a TensorFlow graph.
with tf.name_scope("placeholders"):
x = tf.constant(x_np, dtype=tf.float32)
y = tf.constant(y_np, dtype=tf.float32)
with tf.name_scope("weights"):
W = tf.Variable(tf.random.normal((2, 1)))
b = tf.Variable(tf.random.normal((1,)))
with tf.name_scope("prediction"):
y_logit = tf.squeeze(tf.matmul(x, W) + b)
# the sigmoid gives the class probability of 1
y_one_prob = tf.sigmoid(y_logit)
# Rounding P(y=1) will give the correct prediction.
y_pred = tf.round(y_one_prob)
with tf.name_scope("loss"):
# Compute the cross-entropy term for each datapoint
entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y)
# Sum all contributions
l = tf.reduce_sum(entropy)
with tf.name_scope("optim"):
train_op = tf.compat.v1.train.AdamOptimizer(.01).minimize(l)
with tf.name_scope("summaries"):
tf.compat.v1.summary.scalar("loss", l)
merged = tf.compat.v1.summary.merge_all()
train_writer = tf.compat.v1.summary.FileWriter('logistic-train',
tf.compat.v1.get_default_graph())
#4) Train the model, get the weights, and make predictions.
#5) Plot the predicted outputs on top of the data.

More Related Content

Similar to Please help fill in the missing code below in order for it run correct.docx

ML with python.pdf
ML with python.pdfML with python.pdf
ML with python.pdfn58648017
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to TensorflowTzar Umang
 
Essential numpy before you start your Machine Learning journey in python.pdf
Essential numpy before you start your Machine Learning journey in python.pdfEssential numpy before you start your Machine Learning journey in python.pdf
Essential numpy before you start your Machine Learning journey in python.pdfSmrati Kumar Katiyar
 
Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Piotr Milanowski
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdfsrxerox
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 
[신경망기초] 합성곱신경망
[신경망기초] 합성곱신경망[신경망기초] 합성곱신경망
[신경망기초] 합성곱신경망jaypi Ko
 
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...DineshThallapelly
 
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docximport os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docxBlake0FxCampbelld
 
Please help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdfPlease help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdfclimatecontrolsv
 

Similar to Please help fill in the missing code below in order for it run correct.docx (20)

ML with python.pdf
ML with python.pdfML with python.pdf
ML with python.pdf
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to Tensorflow
 
NUMPY-2.pptx
NUMPY-2.pptxNUMPY-2.pptx
NUMPY-2.pptx
 
FYP Final Presentation
FYP Final PresentationFYP Final Presentation
FYP Final Presentation
 
Essential numpy before you start your Machine Learning journey in python.pdf
Essential numpy before you start your Machine Learning journey in python.pdfEssential numpy before you start your Machine Learning journey in python.pdf
Essential numpy before you start your Machine Learning journey in python.pdf
 
Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Kalman filter
Kalman filterKalman filter
Kalman filter
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
Codecomparaison
CodecomparaisonCodecomparaison
Codecomparaison
 
[신경망기초] 합성곱신경망
[신경망기초] 합성곱신경망[신경망기초] 합성곱신경망
[신경망기초] 합성곱신경망
 
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
 
chapter5.pdf
chapter5.pdfchapter5.pdf
chapter5.pdf
 
R normal distribution
R   normal distributionR   normal distribution
R normal distribution
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
 
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docximport os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
 
Please help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdfPlease help this code is supposed to evaluate current node state and i.pdf
Please help this code is supposed to evaluate current node state and i.pdf
 

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 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
 
Pester Company transferred the following assets to a newly created sub.docx
Pester Company transferred the following assets to a newly created sub.docxPester Company transferred the following assets to a newly created sub.docx
Pester Company transferred the following assets to a newly created sub.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 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
 
Pester Company transferred the following assets to a newly created sub.docx
Pester Company transferred the following assets to a newly created sub.docxPester Company transferred the following assets to a newly created sub.docx
Pester Company transferred the following assets to a newly created sub.docx
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
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 🔝✔️✔️
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 

Please help fill in the missing code below in order for it run correct.docx

  • 1. Please help fill in the missing code below in order for it run correctly. Areas that are needed/missing are in highlighted in bold . import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #1) Generate the synthetic data using the following Python code snippet. # Generate synthetic data N = 100 # Zeros form a Gaussian centered at (-1, -1) x_zeros = np.random.multivariate_normal(mean=np.array((-1, -1)), cov=.1*np.eye(2), size=(N//2,)) y_zeros = np.zeros((N//2,)) # Ones form a Gaussian centered at (1, 1) x_ones = np.random.multivariate_normal(mean=np.array((1, 1)), cov=.1*np.eye(2), size=(N//2,)) y_ones = np.ones((N//2,)) x_np = np.vstack([x_zeros, x_ones]) y_np = np.concatenate([y_zeros, y_ones]) # Plot x_zeros and x_ones on the same graph plt.scatter(x_zeros[:,0], x_zeros[:,1], label='class 0') plt.scatter(x_ones[:,0], x_ones[:,1], label='class 1') plt.legend() plt.show() #3) Generate a TensorFlow graph.
  • 2. with tf.name_scope("placeholders"): x = tf.constant(x_np, dtype=tf.float32) y = tf.constant(y_np, dtype=tf.float32) with tf.name_scope("weights"): W = tf.Variable(tf.random.normal((2, 1))) b = tf.Variable(tf.random.normal((1,))) with tf.name_scope("prediction"): y_logit = tf.squeeze(tf.matmul(x, W) + b) # the sigmoid gives the class probability of 1 y_one_prob = tf.sigmoid(y_logit) # Rounding P(y=1) will give the correct prediction. y_pred = tf.round(y_one_prob) with tf.name_scope("loss"): # Compute the cross-entropy term for each datapoint entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y) # Sum all contributions l = tf.reduce_sum(entropy) with tf.name_scope("optim"): train_op = tf.compat.v1.train.AdamOptimizer(.01).minimize(l) with tf.name_scope("summaries"): tf.compat.v1.summary.scalar("loss", l) merged = tf.compat.v1.summary.merge_all() train_writer = tf.compat.v1.summary.FileWriter('logistic-train', tf.compat.v1.get_default_graph())
  • 3. #4) Train the model, get the weights, and make predictions. #5) Plot the predicted outputs on top of the data. import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #1) Generate the synthetic data using the following Python code snippet. # Generate synthetic data N = 100 # Zeros form a Gaussian centered at (-1, -1) x_zeros = np.random.multivariate_normal(mean=np.array((-1, -1)), cov=.1*np.eye(2), size=(N//2,)) y_zeros = np.zeros((N//2,)) # Ones form a Gaussian centered at (1, 1) x_ones = np.random.multivariate_normal(mean=np.array((1, 1)), cov=.1*np.eye(2), size=(N//2,)) y_ones = np.ones((N//2,)) x_np = np.vstack([x_zeros, x_ones]) y_np = np.concatenate([y_zeros, y_ones]) # Plot x_zeros and x_ones on the same graph plt.scatter(x_zeros[:,0], x_zeros[:,1], label='class 0') plt.scatter(x_ones[:,0], x_ones[:,1], label='class 1') plt.legend()
  • 4. plt.show() #3) Generate a TensorFlow graph. with tf.name_scope("placeholders"): x = tf.constant(x_np, dtype=tf.float32) y = tf.constant(y_np, dtype=tf.float32) with tf.name_scope("weights"): W = tf.Variable(tf.random.normal((2, 1))) b = tf.Variable(tf.random.normal((1,))) with tf.name_scope("prediction"): y_logit = tf.squeeze(tf.matmul(x, W) + b) # the sigmoid gives the class probability of 1 y_one_prob = tf.sigmoid(y_logit) # Rounding P(y=1) will give the correct prediction. y_pred = tf.round(y_one_prob) with tf.name_scope("loss"): # Compute the cross-entropy term for each datapoint entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y) # Sum all contributions l = tf.reduce_sum(entropy) with tf.name_scope("optim"): train_op = tf.compat.v1.train.AdamOptimizer(.01).minimize(l) with tf.name_scope("summaries"): tf.compat.v1.summary.scalar("loss", l)
  • 5. merged = tf.compat.v1.summary.merge_all() train_writer = tf.compat.v1.summary.FileWriter('logistic-train', tf.compat.v1.get_default_graph()) #4) Train the model, get the weights, and make predictions. #5) Plot the predicted outputs on top of the data.