SlideShare a Scribd company logo
Need help filling out the missing sections of this code. the sections missing are step 6, 7, and 9.
Step 1: Load the Tox21 Dataset.
import numpy as np
np.random.seed(456)
import tensorflow as tf
tf.set_random_seed(456)
import matplotlib.pyplot as plt
import deepchem as dc
from sklearn.metrics import accuracy_score
_, (train, valid, test), _ = dc.molnet.load_tox21()
train_X, train_y, train_w = train.X, train.y, train.w
valid_X, valid_y, valid_w = valid.X, valid.y, valid.w
test_X, test_y, test_w = test.X, test.y, test.w
Step 2: Remove extra datasets.
# Remove extra tasks
train_y = train_y[:, 0]
valid_y = valid_y[:, 0]
test_y = test_y[:, 0]
train_w = train_w[:, 0]
valid_w = valid_w[:, 0]
test_w = test_w[:, 0]
Step 3: Define placeholders that accept minibatches of different sizes.
# Generate tensorflow graph
d = 1024
n_hidden = 50
learning_rate = .001
n_epochs = 10
batch_size = 100
with tf.name_scope("placeholders"):
x = tf.placeholder(tf.float32, (None, d))
y = tf.placeholder(tf.float32, (None,))
Step 4: Implement a hidden layer.
with tf.name_scope("hidden-layer"):
W = tf.Variable(tf.random_normal((d, n_hidden)))
b = tf.Variable(tf.random_normal((n_hidden,)))
x_hidden = tf.nn.relu(tf.matmul(x, W) + b)
Step 5: Complete the fully connected architecture.
with tf.name_scope("output"):
W = tf.Variable(tf.random_normal((n_hidden, 1)))
b = tf.Variable(tf.random_normal((1,)))
y_logit = tf.matmul(x_hidden, 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
y_expand = tf.expand_dims(y, 1)
entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y_expand)
# Sum all contributions
l = tf.reduce_sum(entropy)
with tf.name_scope("optim"):
train_op = tf.train.AdamOptimizer(learning_rate).minimize(l)
with tf.name_scope("summaries"):
tf.summary.scalar("loss", l)
merged = tf.summary.merge_all()
Step 6: Add dropout to a hidden layer.
Step 7: Define a hidden layer with dropout.
Step 8: Implement mini-batching training.
train_writer = tf.summary.FileWriter('/tmp/fcnet-tox21',
tf.get_default_graph())
N = train_X.shape[0]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
step = 0
for epoch in range(n_epochs):
pos = 0
while pos N:
batch_X = train_X[pos:pos+batch_size]
batch_y = train_y[pos:pos+batch_size]
feed_dict = {x: batch_X, y: batch_y}
_, summary, loss = sess.run([train_op, merged, l], feed_dict=feed_dict)
print("epoch %d, step %d, loss: %f" % (epoch, step, loss))
train_writer.add_summary(summary, step)
step += 1
pos += batch_size
# Make Predictions
valid_y_pred = sess.run(y_pred, feed_dict={x: valid_X})
Step 9: Use TensorBoard to track model convergence.
include screenshots for the following:
1) a TensorBoard graph for the model, and
2) the loss curve.
Step 1: Load the Tox21 Dataset.
import numpy as np
np.random.seed(456)
import tensorflow as tf
tf.set_random_seed(456)
import matplotlib.pyplot as plt
import deepchem as dc
from sklearn.metrics import accuracy_score
_, (train, valid, test), _ = dc.molnet.load_tox21()
train_X, train_y, train_w = train.X, train.y, train.w
valid_X, valid_y, valid_w = valid.X, valid.y, valid.w
test_X, test_y, test_w = test.X, test.y, test.w
Step 2: Remove extra datasets.
# Remove extra tasks
train_y = train_y[:, 0]
valid_y = valid_y[:, 0]
test_y = test_y[:, 0]
train_w = train_w[:, 0]
valid_w = valid_w[:, 0]
test_w = test_w[:, 0]
Step 3: Define placeholders that accept minibatches of different sizes.
# Generate tensorflow graph
d = 1024
n_hidden = 50
learning_rate = .001
n_epochs = 10
batch_size = 100
with tf.name_scope("placeholders"):
x = tf.placeholder(tf.float32, (None, d))
y = tf.placeholder(tf.float32, (None,))
Step 4: Implement a hidden layer.
with tf.name_scope("hidden-layer"):
W = tf.Variable(tf.random_normal((d, n_hidden)))
b = tf.Variable(tf.random_normal((n_hidden,)))
x_hidden = tf.nn.relu(tf.matmul(x, W) + b)
Step 5: Complete the fully connected architecture.
with tf.name_scope("output"):
W = tf.Variable(tf.random_normal((n_hidden, 1)))
b = tf.Variable(tf.random_normal((1,)))
y_logit = tf.matmul(x_hidden, 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
y_expand = tf.expand_dims(y, 1)
entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit,
labels=y_expand)
# Sum all contributions
l = tf.reduce_sum(entropy)
with tf.name_scope("optim"):
train_op = tf.train.AdamOptimizer(learning_rate).minimize(l)
with tf.name_scope("summaries"):
tf.summary.scalar("loss", l)
merged = tf.summary.merge_all()
Step 6: Add dropout to a hidden layer.
Step 7: Define a hidden layer with dropout.
Step 8: Implement mini-batching training.
train_writer = tf.summary.FileWriter('/tmp/fcnet-tox21',
tf.get_default_graph())
N = train_X.shape[0]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
step = 0
for epoch in range(n_epochs):
pos = 0
while pos N:
batch_X = train_X[pos:pos+batch_size]
batch_y = train_y[pos:pos+batch_size]
feed_dict = {x: batch_X, y: batch_y}
_, summary, loss = sess.run([train_op, merged, l], feed_dict=feed_dict)
print("epoch %d, step %d, loss: %f" % (epoch, step, loss))
train_writer.add_summary(summary, step)
step += 1
pos += batch_size
# Make Predictions
valid_y_pred = sess.run(y_pred, feed_dict={x: valid_X})
Step 9: Use TensorBoard to track model convergence.
Need help filling out the missing sections of this code- the sections.docx

More Related Content

Similar to Need help filling out the missing sections of this code- the sections.docx

Machine Learning and Go. Go!
Machine Learning and Go. Go!Machine Learning and Go. Go!
Machine Learning and Go. Go!
Diana Ortega
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117
Ganesan Narayanasamy
 
Neural networks with python
Neural networks with pythonNeural networks with python
Neural networks with python
Simone Piunno
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
Max Kleiner
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Paulo Sergio Lemes Queiroz
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
Oswald Campesato
 
ML Assignment help.pptx
ML Assignment help.pptxML Assignment help.pptx
ML Assignment help.pptx
Robinjk
 
Mpi in-python
Mpi in-pythonMpi in-python
Mpi in-python
A Jorge Garcia
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
pramodkumar1804
 
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
ETS Asset Management Factory
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Codemotion
 
TensorFlow in Practice
TensorFlow in PracticeTensorFlow in Practice
TensorFlow in Practice
indico data
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
rik0
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
PyCon Italia
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
Mark Chang
 
Assignment 5.2.pdf
Assignment 5.2.pdfAssignment 5.2.pdf
Assignment 5.2.pdf
dash41
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
홍배 김
 
Assignment 6.2a.pdf
Assignment 6.2a.pdfAssignment 6.2a.pdf
Assignment 6.2a.pdf
dash41
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016
Andrii Babii
 

Similar to Need help filling out the missing sections of this code- the sections.docx (20)

Machine Learning and Go. Go!
Machine Learning and Go. Go!Machine Learning and Go. Go!
Machine Learning and Go. Go!
 
Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117Power ai tensorflowworkloadtutorial-20171117
Power ai tensorflowworkloadtutorial-20171117
 
Neural networks with python
Neural networks with pythonNeural networks with python
Neural networks with python
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Pythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPUPythonbrasil - 2018 - Acelerando Soluções com GPU
Pythonbrasil - 2018 - Acelerando Soluções com GPU
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
 
ML Assignment help.pptx
ML Assignment help.pptxML Assignment help.pptx
ML Assignment help.pptx
 
Mpi in-python
Mpi in-pythonMpi in-python
Mpi in-python
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
 
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
Python + Tensorflow: how to earn money in the Stock Exchange with Deep Learni...
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
 
TensorFlow in Practice
TensorFlow in PracticeTensorFlow in Practice
TensorFlow in Practice
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
Assignment 5.2.pdf
Assignment 5.2.pdfAssignment 5.2.pdf
Assignment 5.2.pdf
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
 
Assignment 6.2a.pdf
Assignment 6.2a.pdfAssignment 6.2a.pdf
Assignment 6.2a.pdf
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016
 

More from lauracallander

Match the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docxMatch the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docx
lauracallander
 
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docxMatrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
lauracallander
 
Modify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docxModify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docx
lauracallander
 
Michelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docxMichelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docx
lauracallander
 
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docxMechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
lauracallander
 
Match each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docxMatch each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docx
lauracallander
 
Match the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docxMatch the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docx
lauracallander
 
Match the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docxMatch the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docx
lauracallander
 
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docxMatch the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
lauracallander
 
Match the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docxMatch the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docx
lauracallander
 
Match the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docxMatch the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docx
lauracallander
 
Match each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docxMatch each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docx
lauracallander
 
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docxMikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
lauracallander
 
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docxMike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
lauracallander
 
Michael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docxMichael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docx
lauracallander
 
microbiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docxmicrobiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docx
lauracallander
 
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docxNova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
lauracallander
 
Marlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docxMarlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docx
lauracallander
 
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docxNote the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
lauracallander
 
Not all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docxNot all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docx
lauracallander
 

More from lauracallander (20)

Match the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docxMatch the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docx
 
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docxMatrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
 
Modify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docxModify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docx
 
Michelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docxMichelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docx
 
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docxMechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
 
Match each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docxMatch each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docx
 
Match the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docxMatch the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docx
 
Match the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docxMatch the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docx
 
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docxMatch the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
 
Match the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docxMatch the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docx
 
Match the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docxMatch the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docx
 
Match each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docxMatch each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docx
 
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docxMikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
 
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docxMike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
 
Michael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docxMichael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docx
 
microbiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docxmicrobiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docx
 
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docxNova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
 
Marlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docxMarlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docx
 
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docxNote the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
 
Not all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docxNot all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docx
 

Recently uploaded

Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 

Recently uploaded (20)

Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 

Need help filling out the missing sections of this code- the sections.docx

  • 1. Need help filling out the missing sections of this code. the sections missing are step 6, 7, and 9. Step 1: Load the Tox21 Dataset. import numpy as np np.random.seed(456) import tensorflow as tf tf.set_random_seed(456) import matplotlib.pyplot as plt import deepchem as dc from sklearn.metrics import accuracy_score _, (train, valid, test), _ = dc.molnet.load_tox21() train_X, train_y, train_w = train.X, train.y, train.w valid_X, valid_y, valid_w = valid.X, valid.y, valid.w test_X, test_y, test_w = test.X, test.y, test.w Step 2: Remove extra datasets. # Remove extra tasks train_y = train_y[:, 0] valid_y = valid_y[:, 0] test_y = test_y[:, 0] train_w = train_w[:, 0] valid_w = valid_w[:, 0] test_w = test_w[:, 0] Step 3: Define placeholders that accept minibatches of different sizes. # Generate tensorflow graph
  • 2. d = 1024 n_hidden = 50 learning_rate = .001 n_epochs = 10 batch_size = 100 with tf.name_scope("placeholders"): x = tf.placeholder(tf.float32, (None, d)) y = tf.placeholder(tf.float32, (None,)) Step 4: Implement a hidden layer. with tf.name_scope("hidden-layer"): W = tf.Variable(tf.random_normal((d, n_hidden))) b = tf.Variable(tf.random_normal((n_hidden,))) x_hidden = tf.nn.relu(tf.matmul(x, W) + b) Step 5: Complete the fully connected architecture. with tf.name_scope("output"): W = tf.Variable(tf.random_normal((n_hidden, 1))) b = tf.Variable(tf.random_normal((1,))) y_logit = tf.matmul(x_hidden, 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"):
  • 3. # Compute the cross-entropy term for each datapoint y_expand = tf.expand_dims(y, 1) entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y_expand) # Sum all contributions l = tf.reduce_sum(entropy) with tf.name_scope("optim"): train_op = tf.train.AdamOptimizer(learning_rate).minimize(l) with tf.name_scope("summaries"): tf.summary.scalar("loss", l) merged = tf.summary.merge_all() Step 6: Add dropout to a hidden layer. Step 7: Define a hidden layer with dropout. Step 8: Implement mini-batching training. train_writer = tf.summary.FileWriter('/tmp/fcnet-tox21', tf.get_default_graph()) N = train_X.shape[0] with tf.Session() as sess: sess.run(tf.global_variables_initializer()) step = 0 for epoch in range(n_epochs): pos = 0 while pos N: batch_X = train_X[pos:pos+batch_size]
  • 4. batch_y = train_y[pos:pos+batch_size] feed_dict = {x: batch_X, y: batch_y} _, summary, loss = sess.run([train_op, merged, l], feed_dict=feed_dict) print("epoch %d, step %d, loss: %f" % (epoch, step, loss)) train_writer.add_summary(summary, step) step += 1 pos += batch_size # Make Predictions valid_y_pred = sess.run(y_pred, feed_dict={x: valid_X}) Step 9: Use TensorBoard to track model convergence. include screenshots for the following: 1) a TensorBoard graph for the model, and 2) the loss curve. Step 1: Load the Tox21 Dataset. import numpy as np np.random.seed(456) import tensorflow as tf tf.set_random_seed(456) import matplotlib.pyplot as plt import deepchem as dc from sklearn.metrics import accuracy_score _, (train, valid, test), _ = dc.molnet.load_tox21() train_X, train_y, train_w = train.X, train.y, train.w
  • 5. valid_X, valid_y, valid_w = valid.X, valid.y, valid.w test_X, test_y, test_w = test.X, test.y, test.w Step 2: Remove extra datasets. # Remove extra tasks train_y = train_y[:, 0] valid_y = valid_y[:, 0] test_y = test_y[:, 0] train_w = train_w[:, 0] valid_w = valid_w[:, 0] test_w = test_w[:, 0] Step 3: Define placeholders that accept minibatches of different sizes. # Generate tensorflow graph d = 1024 n_hidden = 50 learning_rate = .001 n_epochs = 10 batch_size = 100 with tf.name_scope("placeholders"): x = tf.placeholder(tf.float32, (None, d)) y = tf.placeholder(tf.float32, (None,)) Step 4: Implement a hidden layer. with tf.name_scope("hidden-layer"): W = tf.Variable(tf.random_normal((d, n_hidden)))
  • 6. b = tf.Variable(tf.random_normal((n_hidden,))) x_hidden = tf.nn.relu(tf.matmul(x, W) + b) Step 5: Complete the fully connected architecture. with tf.name_scope("output"): W = tf.Variable(tf.random_normal((n_hidden, 1))) b = tf.Variable(tf.random_normal((1,))) y_logit = tf.matmul(x_hidden, 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 y_expand = tf.expand_dims(y, 1) entropy = tf.nn.sigmoid_cross_entropy_with_logits(logits=y_logit, labels=y_expand) # Sum all contributions l = tf.reduce_sum(entropy) with tf.name_scope("optim"): train_op = tf.train.AdamOptimizer(learning_rate).minimize(l) with tf.name_scope("summaries"): tf.summary.scalar("loss", l) merged = tf.summary.merge_all()
  • 7. Step 6: Add dropout to a hidden layer. Step 7: Define a hidden layer with dropout. Step 8: Implement mini-batching training. train_writer = tf.summary.FileWriter('/tmp/fcnet-tox21', tf.get_default_graph()) N = train_X.shape[0] with tf.Session() as sess: sess.run(tf.global_variables_initializer()) step = 0 for epoch in range(n_epochs): pos = 0 while pos N: batch_X = train_X[pos:pos+batch_size] batch_y = train_y[pos:pos+batch_size] feed_dict = {x: batch_X, y: batch_y} _, summary, loss = sess.run([train_op, merged, l], feed_dict=feed_dict) print("epoch %d, step %d, loss: %f" % (epoch, step, loss)) train_writer.add_summary(summary, step) step += 1 pos += batch_size # Make Predictions valid_y_pred = sess.run(y_pred, feed_dict={x: valid_X}) Step 9: Use TensorBoard to track model convergence.