EME 210
Data Analytics for Energy Systems

Neurons and Transfer Function

PrintPrint

Read It: Neurons and Transfer Function

Enter image and alt text here. No sizes!
ADD IMAGE: L27:Slide 7
Enter image credit here

[00:33:10.72] So then what's going on at the neurons? Let's take a closer look. Let's zoom in on these neurons here. So, at each neuron, you've got the values coming in from the nodes at the previous layer. So, these might be your direct inputs from the input layer, or these might be from the first hidden layer or what-have-you.  

[00:33:34.77] But you've got some values streaming in from, again, each neuron in the previous-- or each node in the previous layer. So x1, x2, xn. And then we've got our synaptic weights-- our weights. I'm going to label them w-- so w1, 2, n for each of these connectors.  

[00:33:56.77] Then we've got our node. And in our node is a function. So, I'm just going to call it f with parentheses. We just have some function, and I'll talk more about what sorts of functions we could put in here.  

[00:34:09.01] And then it's going to spit out a value. Let's call it y. And then ultimately, this y could go on to each and every node that's in the next layer. But for now, let's just simplify it and just say y.  

[00:34:27.46] So we'll define those. And so, our y is going to be equal to this function, applied to the sum of the product of each weight in each x. So, you do x1 times w1 plus x2 times w2 plus x3 times w3, on and on and on to xn times wn, and add those all up.  

[00:34:52.07] So the weight times x, just like how we had in linear regression-- we had the betas times the x's. Here it's the weights times x's. So now we're going to add those all up and wrap them in some function-- some crazy function here.  

[00:35:09.24] What's going on with this function? This function is called a transfer function. It's typically non-linear, although some of them are linear. One rule about these transfer functions is that they need to be continuously differentiable and monotonically increasing, whatever that means.  

[00:35:30.67] It just means that they need to be more or less smooth over x. And they need to continue to increase. They can't decrease as we go from left to right over x. So, let's look at some examples of these functions.  


Try It: OPTION 1 GOOGLE COLAB

  1. Click the Google Colab file used in the video here.
  2. Go to the Colab file and click "File" then "Save a copy in Drive", this will create a new Colab file that you can edit in your own Google Drive account.
  3. Once you have it saved in your Drive, try to implement the following code to import a file of your choice by mounting your Google Drive:

Note: You must be logged into your PSU Google Workspace in order to access the file.

from google.colab import drive

drive.mount('/content/drive')

import pandas as pd

df = pd.read_csv('yourfilename.csv')

df # print the dataframe

Once you have implemented this code on your own, come back to this page to test your knowledge.


OPTION 2 : DATACAMP

 Try It: OPTION 2 DataCamp - Apply Your Coding Skills

Dictionaries are a quick way to create a variable from scratch. However, their functionality is limited, so we will often want to convert those dictionaries into DataFrames. Try to code this conversion in the cell below. Hint: Make sure to import the Pandas library.

# This will get executed each time the exercise gets initialized. # Create a Simple Dictionary mydict = {'Name':['Amy', 'Bob', 'Clair', 'Daisy'], 'Birthday':['9/3/1991', '4/21/1988', '4/21/1990', '11/11/1989'], 'Age':[31, 34, 32, 33]} # convert the dictionary to a DataFrame # print the values in the 'Birthday' column # Create a Simple Dictionary mydict = {'Name':['Amy', 'Bob', 'Clair', 'Daisy'], 'Birthday':['9/3/1991', '4/21/1988', '4/21/1990', '11/11/1989'], 'Age':[31, 34, 32, 33]} # convert the dictionary to a DataFrame import pandas as pd mydataframe = pd.DataFrame(mydict) # print the values in the 'Birthday' column mydataframe['Birthday']


Assess It: Check Your Knowledge

Knowledge Check (replace question)