<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <div class="alert alert-block alert-info" style="margin-top
Step1:  <a id="ref0"></a>
<h2> Logistic Function </h2>
Step2:  Create a tensor ranging from -10 to 10
Step3:  When you use sequential, you can create a sigmoid object
Step4:  Apply the element-wise function Sigmoid with the object
Step5:  Plot the results
Step6:  For custom modules, call the sigmoid from the torch (nn.functional for the old version), which applies the element-wise sigmoid from the function module and plots the results
Step7:  w=torch.te
<a id="ref1"></a>
<h2> Tanh  </h2>
When you use sequential, you can create a tanh object
Step8:  Call the object and plot it
Step9:  For custom modules, call the Tanh object from the torch (nn.functional for the old version), which applies the element-wise sigmoid from the function module and plots the results
Step10:  <a id="ref3"></a>
<h2> Relu </h2>
When you use sequential, you can create a Relu object
Step11:  For custom modules, call the relu object from the nn.functional, which applies the element-wise sigmoid from the function module and plots the results
Step12:  <a id="ref3"></a>
<h2> Compare Activation Functions </h2>
<ASSISTANT_TASK:>
Python Code:
import torch.nn as nn
import torch
import torch.nn.functional as F
import matplotlib.pyplot as plt 
Explanation: <div class="alert alert-block alert-info" style="margin-top: 20px">
 <a href="http://cocl.us/pytorch_link_top"><img src = "http://cocl.us/Pytorch_top" width = 950, align = "center"></a>
<img src = "https://ibm.box.com/shared/static/ugcqz6ohbvff804xp84y4kqnvvk3bq1g.png" width = 200, align = "center">
<h1 align=center><font size = 5>Logistic Regression</font></h1> 
In this lab, you will cover logistic regression by using Pytorch. 
# Table of Contents
<div class="alert alert-block alert-info" style="margin-top: 20px">
<li><a href="#ref0">Logistic Function</a></li>
<li><a href="#ref1">Tach</a></li>
<li><a href="#ref2">Rulu</a></li>
<li><a href="#ref3">Compare Activation Functions</a></li>
<li><a href="#ref4">Practice</a></li>
<br>
<p></p>
Estimated Time Needed: <strong>15 min</strong>
</div>
<hr>
Import all the necessary modules:
End of explanation
torch.manual_seed(2)
Explanation: <a id="ref0"></a>
<h2> Logistic Function </h2>
End of explanation
z=torch.arange(-10,10,0.1).view(-1, 1)
Explanation: Create a tensor ranging from -10 to 10:
End of explanation
sig=nn.Sigmoid()
Explanation: When you use sequential, you can create a sigmoid object:
End of explanation
yhat=sig(z)
sig(torch.tensor(-1.0))
Explanation: Apply the element-wise function Sigmoid with the object:
End of explanation
plt.plot(z.numpy(),yhat.numpy())
plt.xlabel('z')
plt.ylabel('yhat')
Explanation: Plot the results:
End of explanation
yhat=torch.sigmoid(z)
plt.plot(z.numpy(),yhat.numpy())
Explanation: For custom modules, call the sigmoid from the torch (nn.functional for the old version), which applies the element-wise sigmoid from the function module and plots the results:
End of explanation
TANH=nn.Tanh()
Explanation: w=torch.te
<a id="ref1"></a>
<h2> Tanh  </h2>
When you use sequential, you can create a tanh object:
End of explanation
yhat=TANH(z)
plt.plot(z.numpy(),yhat.numpy())
Explanation: Call the object and plot it:
End of explanation
yhat=torch.tanh(z)
plt.plot(z.numpy(),yhat.numpy())
Explanation: For custom modules, call the Tanh object from the torch (nn.functional for the old version), which applies the element-wise sigmoid from the function module and plots the results:
End of explanation
RELU=nn.ReLU()
yhat=RELU(z)
plt.plot(z.numpy(),yhat.numpy())
Explanation: <a id="ref3"></a>
<h2> Relu </h2>
When you use sequential, you can create a Relu object:
End of explanation
yhat=F.relu(z)
plt.plot(z.numpy(),yhat.numpy())
Explanation: For custom modules, call the relu object from the nn.functional, which applies the element-wise sigmoid from the function module and plots the results:
End of explanation
x=torch.arange(-2,2,0.1).view(-1, 1)
plt.plot(x.numpy(),F.relu(x).numpy(),label='relu')
plt.plot(x.numpy(),torch.sigmoid(x).numpy(),label='sigmoid')
plt.plot(x.numpy(),torch.tanh(x).numpy(),label='tanh')
plt.legend()
Explanation: <a id="ref3"></a>
<h2> Compare Activation Functions </h2>
End of explanation
<END_TASK>