Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part One: Compute K [Graded] In computek, you are going to calcuate the values of different kernel functions given inputs X and Z. You

student submitted image, transcription available below

student submitted image, transcription available below

student submitted image, transcription available below

student submitted image, transcription available below

student submitted image, transcription available below  
 
 
 

Part One: Compute K [Graded] In computek, you are going to calcuate the values of different kernel functions given inputs X and Z. You will return K = K(X,Z). Kij = k(xi, Zj) where k(xi, z;) = (x)(z;). This function takes in the parameter kerneltype to decide which of the three different kernel functions to evaluate. To review, recall the following types of kernels: Linear: K(X, Z) = XTZ Polynomial: K(X, Z) = (XTZ + 1)d where kpar = d RBF: K(X, Z) = exp(-1x-||| -} where kpar = 1 Note: When calculating the RBF kernel, you can use the 12distance (X, Z) functions to calculate the pairwise 12 distance efficiently. def computek (kerneltype, X, Z, kpar=1): function K computek (kernel_type, X, Z) computes a matrix K such that Kij=k(x, z); for three different function linear, rbf or polynomial. Input: kerneltype: either 'linear', 'polynomial', 'rbf' X: n input vectors of dimension d (nxd); Z: m input vectors of dimension d (mxd); kpar: kernel parameter (inverse kernel width gamma in case of RBF, degree in case of polynomial) OUTPUT: K nxm kernel matrix assert kerneltype in ["linear","polynomial", "rbf"], "Kernel type %s not known." % kerneltype assert X.shape[1] K = None # YOUR CODE HERE == Z.shape[1], "Input dimensions do not match" raise NotImplementedError() return K

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

The Commanding Heights The Battle For The World Economy

Authors: Daniel Yergin, Joseph Stanislaw

1st Edition

068483569X, 9780684835693

More Books

Students also viewed these Economics questions