Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I used python with the code below. Not sure what is wrong T4-HW4.7. Floating Point and Softmax The softmax function normalizes a vector so its

image text in transcribed

image text in transcribed

I used python with the code below. Not sure what is wrong

image text in transcribed

T4-HW4.7. Floating Point and Softmax The softmax function normalizes a vector so its entries are positive and sum to 1. This is useful for creating a probability distribution across the vector, so it is commonly used as the final activation layer for neural networks (especially since the gradient of the softmax function is relatively easy to compute). The softmax function is defined as follows, for a vector z ERD where D is the length of the vector: ez; 0(z); for j = 1, ...,D D i=1 ez In essence, the numerator scales each term of the vector to some non-negative value, and then the denominator normalizes the vector to sum up to 1. Let z= [20 85.19757 86.82316 86.15644] Assume z is represented in single-precision floating-point. When calculating the result of the softmax function on z, what is the maximum value that zo can take to avoid overflow in the calculations? 20 = 88.588 x 0% Correct answer 20 = 88.427 Submitted answer incorrect: 0% Submitted at 2021-02-15 10:28:52 (CST) 20 = 88.588 X 0% In [1]: import numpy as np In [2] : max_val np.finfo(np. float32).max In [15]: N 1 = np.array([85.19757, 84.82316, 86.15644], dtype=np.float32) j = max_val - np.sum (np.exp(1)) print("The maximum permissible value of zo is " + str(np.log(j))) The maximum permissible value of zo is 88.587585 In [ ]: N

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Discuss the challenges in scanning the environment.

Answered: 1 week ago

Question

Question What integration level should an employer choose?

Answered: 1 week ago