Question

In: Computer Science

Write a function softMax_M(Q) to return a 2darray of softmax function values ??ℎ=???ℎ−?∑??=1???ℎ−? for ?=0,1,⋯,?−1,ℎ=0,1,⋯,?−1 ,...

Write a function softMax_M(Q) to return a 2darray of softmax function values ??ℎ=???ℎ−?∑??=1???ℎ−? for ?=0,1,⋯,?−1,ℎ=0,1,⋯,?−1 , where ? is a 2darray of floats with shape ( ? , ? ), ??ℎ is the element at the (?+1) -th row and the (ℎ+1) -th column of array ? , and ? is the largest element in array ? . (Hint: operations should be performed down the rows; a returned 2darray and ? are of the same shape.) Sample: if D = np.array([[10, 9], [5, 6], [8, 4]]), then softMax_M(D) returns array([[0.876, 0.946], [0.006, 0.047], [0.118, 0.006]]).

in python program

i just want the answer in python program

Solutions

Expert Solution

please please thumbs up!!!

hope it will help uh out!!!

Code::

(IN PYTHON PROGRAMMING LANGUAGE)

------------------------------------------------------------

#import numpy module
import numpy as np
#function which computes softmax function values for the given 1-d numpy array z.
def softMax(z):
#computing using softmax function formula
return np.exp(z) / np.sum(np.exp(z), axis=0)
#1-d numpy array
z=np.array([[10, 9], [5, 6], [8, 4]])
#call softMax() and get the result
vec=softMax(z)
#Now vec contains the result but as expected in the problem the result should be rounded till 3 decimal places
vec=np.around(vec, decimals=3)
#after rounding print
print(vec)

------------------------------------------------------------

output::


Related Solutions

????????? ?ℎ? ??? ?? ?ℎ? ?????? ?? ?ℎ??ℎ ???ℎ ????? ???????? ?? ??????????: 1) ?(?, ?)...
????????? ?ℎ? ??? ?? ?ℎ? ?????? ?? ?ℎ??ℎ ???ℎ ????? ???????? ?? ??????????: 1) ?(?, ?) = ?−? 4−? 2− ?2 2) ?(?, ?, ?) = ln |? 2 + ? 2 − 6| ???? (? 2 − ? 2 + ? 2) 3) ℎ(?, ?, ?) = √? + 2? − ? ? 2 + ? 2
1-Consider the production function ? = ?? ?(?ℎ) 1−? . Transform the production function into per-worker...
1-Consider the production function ? = ?? ?(?ℎ) 1−? . Transform the production function into per-worker terms and show how growth in productivity can be estimated, even though it is not directly observable. Show your work
In Python Create a function called ℎ?????. The function has as arguments a list called ??????...
In Python Create a function called ℎ?????. The function has as arguments a list called ?????? and a list call center. • List ?????? contains lists that represent points. o For example, if ?????? = [[4,2], [3,2], [6,1]], the list [4,2] represents the point with coordinate ? at 4 and y coordinate at 2, and so on for the other lists. Assume that all lists within points contain two numbers (that is, they have x, y coordinates). • List ??????...
1) Sketch the graph of the function ℎ(?) = ?^5⁄3 − 5?^2⁄3 , showing all work...
1) Sketch the graph of the function ℎ(?) = ?^5⁄3 − 5?^2⁄3 , showing all work for domain, intercepts, asymptotes, increase/decrease, relative extrema, and concavity. 2) For the function ?(?) = 2?^2−6/(?−1)^2 , find a) all intercepts, and b) all asymptotes. 3) Determine the concavity of the function ?(?) = ?^2?^−? . 4) Use properties of logarithms to rewrite the expression below as a sum, difference, or multiple of logarithms. ln ?(rad 3)√?^2 + 1 3 5) Use properties of...
let f be the function on [0,1] given by f(x) = 1 if x is different...
let f be the function on [0,1] given by f(x) = 1 if x is different of 1/2 and 2 if x is equal to 1/2 Prove that f is Riemann integrable and compute integral of f(x) dx from 0 to 1 Hint for each epsilon >0 find a partition P so that Up (f) - Lp (f) <= epsilon
Write a function that will take in an array (of type double), and will return the...
Write a function that will take in an array (of type double), and will return the array with all of the elements doubled. You must use pass-by-reference and addressing and/or pointers to accomplish this task. C++
write a function named as cubeCalculator that takes an integer pointer as function and return its...
write a function named as cubeCalculator that takes an integer pointer as function and return its cube value , you are required to compute the cube of a number using pointer notation , return the result as an integer value , use c++
Write hack assembly language code for function (declaration) call (a function) return (from a function)
Write hack assembly language code for function (declaration) call (a function) return (from a function)
How to do the following in R: Write a function that will generate and return a...
How to do the following in R: Write a function that will generate and return a random sample of size n from the twoparameter exponential distribution Exp(λ,ν) for arbitrary n, λ, and ν. Note that the pdf of X ∼ Exp(λ,ν) is f(x) = λe−λ(x−ν),x ≥ ν and λ > 0,ν > 0. Generate a random sample of size 1000 from the Exp(2,1) distribution.
Write a Racket function that will take a list of numbers as a parameter and return...
Write a Racket function that will take a list of numbers as a parameter and return true if they all are positive, and false otherwise. You are NOT required to check the type of elements in the list. (please do on racket language)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT