4

Activation Functions

Unsolved
Neural Networks

Difficulty: 5 | Problem written by hemdan219@gmail.com

Educational Resource: https://cs231n.github.io/neural-networks-1/


Problem reported in interviews at

Apple
Netflix

Given the nodes in a previous hidden layer of a neural network h_output connected to a current node, and the weights weights associated with each of the nodes in h_output, return the resulting node value by taking the dot product of h_output and weights.

The third parameter is a string representing the activation function applied to the intermediate output. The parameter can take the following 4 values:

'sigmoid': Sigmoid(Z) = \({1\over 1+e^{^{(-Z)}}} \)

'tanh': Tanh(Z) =\({e^{^{(Z)}}-e^{^{(-Z)}}\over e^{^{(Z)}}+e^{^{(-Z)}}}\)

'relu': ReLU(Z)=\(max(0,Z)\)

'leakyrelu': ReLULeaky(Z)=\(max(.00001\bullet Z,Z)\)

Sample Input:
<class 'list'>
h_output : [1, 2, 5]
weights: [8, 9, 7]
activation: relu

Expected Output:
<class 'int'>
61

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Molestiae suscipit veniam nostrum dicta fugiat eaque voluptatum quidem voluptas repudiandae, aperiam ex modi animi, provident et aliquid tenetur laboriosam voluptatem, asperiores omnis ratione nisi? Accusamus illum cupiditate ipsum vel, harum quos cumque hic ut nulla similique ab sed ipsum quam, provident neque obcaecati unde eum vitae voluptates quidem doloremque rerum quas, molestias commodi fugiat, culpa officia laborum eligendi eum? Esse ipsam aliquam nam sit voluptatum laborum, repudiandae facere temporibus incidunt dicta placeat eaque voluptates ullam dignissimos.

Aspernatur velit voluptates, modi ut quos quae, reprehenderit at ea quos illum? Illo perspiciatis repudiandae provident sunt sint facilis voluptatum, voluptatem labore eos doloremque architecto nulla accusantium rem laudantium ducimus maiores, debitis similique quas adipisci odio voluptates rem, enim iure animi dolores quae, ab consequatur iste eveniet rem. Rem repellendus modi totam animi similique.

Modi animi nisi excepturi minima itaque iusto ex reiciendis aliquid, fugit suscipit amet quos vitae perferendis minima eius nihil quasi sunt officiis?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)