Question

In: Computer Science

Use Python : Problem Set 01: The network for this task has two input nodes, one...

Use Python :

Problem Set 01:

The network for this task has two input nodes, one hidden layer consisting of two nodes, and one output node. It uses a ReLU activation

function. For the hidden layer, the weights for the first hidden node (from the input nodes) are (2.3, -0.64, 2). The last number is the

weight for the bias term. The weights for the second hidden node are (-3, -2, -1).

For the output layer, the weights are (5, 3, -34).

Calculate the output for the following inputs (where the bias term is the last value of each vector). Show your work.

1. (-4, -2, 1)

2. (0, -2, 1)

3. (4, -2, 1)

4. (0, -3, 1)

Solutions

Expert Solution

Python Program:

import numpy as np

#function for relu activation
def ReLu(layer):
  layer[layer<0]=0
  return layer

def model_output(input_layer):
  #hidden layer weights
  hidden_layer=np.array([[2.3,-0.64,2],[-3,-2,-1]])
  #output layer weights
  output_layer=np.array([[5,3,-34]])
  #hidden layer manipulation
  z1=np.dot(input_layer,np.transpose(hidden_layer))
  a1=ReLu(z1)
  #appending bias to the input of output layer
  bias=np.ones(a1.shape[0]).reshape(a1.shape[0],1)
  a1=np.append(a1,bias,axis=1)
  #output layer manipulation
  z2=np.dot(a1,np.transpose(output_layer))
  a2=ReLu(z2)
  return a2

#input layer units in the formate of numpy array
input_layer=np.array([[-4,-2,1],[0,-2,1],[4,-2,1],[0,-3,1]])
print(model_output(input_layer))

Output:


Related Solutions

Use Python: # Problem Set 01: - Develop neurons and print truth table of the following...
Use Python: # Problem Set 01: - Develop neurons and print truth table of the following 2-input logic gates: AND, OR, NAND, NOR, XOR, XNOR and 1-input NOT gate (Notice: use Markdown to explain how you developed a neuron, and to insert images showing the truth table of logic gates before coding) # Problem Set 02: - Develop neuron and print truth table of XOR gate using only NAND gates - Develop neuron and print truth table of XOR gate...
Use Python ## Problem Set 3 - James is looking for his dream job, but has...
Use Python ## Problem Set 3 - James is looking for his dream job, but has some restrictions. He loves California and would take a job there if it paid over 40,000 a year. He hates Massachusetts and demands at least 100,000 to work there. Any other place he’s content to work for 60,000 a year, unless he can work in space in which case he would work for free. - Write a program to capture the above statement -...
USE PYTHON : # Problem Set 04: - Write a function to seek for all even...
USE PYTHON : # Problem Set 04: - Write a function to seek for all even numbers and odd numbers in the middle of two number A and B. Print even and odd numbers in 1 and 2020 (including both these two numbers) # Problem Set 05: - A website requests an user to input his account password. - Write a program to examize the validity of the password. - The valid password must consists of: - At least 1...
Using Python Question 1 Write an input function. Then use it to supply the input to...
Using Python Question 1 Write an input function. Then use it to supply the input to following additional functions: i) Print multiplication table of the number from 1 to 12. ii) Print the sum of all the numbers from 1 to up the number given. iii) Print if the number supplied is odd or even. Question 2 Write function that asks for input from a user. If the user types 'end', the program exits, otherwise it just keeps going.
Now set up the decision criteria. (Assume α = .01.) This question has two parts: a)...
Now set up the decision criteria. (Assume α = .01.) This question has two parts: a) state the number of tails; and b) state the critical value(s) of the test statistic.
instructions- You have to use Python in order to do this Problem Set. 4 Cobb-Douglas Production...
instructions- You have to use Python in order to do this Problem Set. 4 Cobb-Douglas Production Function Suppose a firm uses the following production function Y = z × K0.3 × N 0.7 d , where Y is output, z is TFP, K is capital, and Nd is labor. 1. Set z = 10, K = 5 and plot the production function over the range Nd ∈ [0, 5] 2. Derive this function w.r.t. Nd.Set z = 10, K =...
This task exercises your ability to use python to represent data and use flow control and...
This task exercises your ability to use python to represent data and use flow control and functions to re-organize the data. You need to submit the ipynb file to Moodle. A data scientist has collected tube information and saved the video info in multiple CSV files. Each CSV file has the following columns: ·         video_id ·         trending_date ·         title ·         channel_title ·         category_id ·         publish_time ·         tags ·         views    ·         likes      ·         dislikes ·         comment_count ·         thumbnail_link ·         comments_disabled     ·         ratings_disabled          ·         video_error_or_removed        ·         description You are asked to write python code to process CSV data...
Hi, I would be grateful for some helot with this Python problem. Your task is to...
Hi, I would be grateful for some helot with this Python problem. Your task is to implement the simple elevator in Python using classes. The default strategy is the simple "start at the bottom, go to the top, then go to the bottom". Can you write a better strategy, one that is more efficient? Description / Specification Create three classes: Building, Elevator, and Customer. Equip the building with an elevator. Ask user to customize the number of floors and the...
Write a Python program which takes a set of positive numbers from the input and returns...
Write a Python program which takes a set of positive numbers from the input and returns the sum of the prime numbers in the given set. The sequence will be ended with a negative number.
USE Python 2.7(screen shot program with output) the task is: takes in a list of protein...
USE Python 2.7(screen shot program with output) the task is: takes in a list of protein sequences as input and finds all the transmembrane domains and returns them in a list for each sequence in the list with given nonpolar regions and returns the lists for those. 1. This code should call two other functions that you write: regionProteinFind takes in a protein sequence and should return a list of 10 amino acid windows, if the sequence is less than...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT