Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def grad ( beta , b , xTr , yTr , xTe, yTe, C , kerneltype, kpar = 1 ) : INPUT:

def grad(beta, b, xTr, yTr, xTe, yTe, C, kerneltype, kpar=1):
"""
INPUT:
beta : n dimensional vector that stores the linear combination coefficient
xTr : nxd dimensional matrix (training set, each row is an input vector)
yTr : n dimensional vector (training label, each entry is a label)
b : scalar (bias)
xTe : mxd dimensional matrix (test set, each row is an input vector)
yTe : m dimensional vector (test label, each entry is a label)
C : scalar (constant that controls the tradeoff between l2-regularizer and hinge-loss)
kerneltype: either 'linear','polynomial','rbf'
kpar : kernel parameter (inverse kernel width gamma in case of RBF, degree in case of polynomial)
OUTPUTS:
beta_grad : n dimensional vector (the gradient of the hinge loss with respect to the alphas)
bgrad : constant (the gradient of he hinge loss with respect to the bias, b)
"""
n, d = xTr.shape
beta_grad = np.zeros(n)
bgrad = np.zeros(1)
# compute the kernel values between xTr and xTr
kernel_train = computeK(kerneltype, xTr, xTr, kpar)
# compute the kernel values between xTe and xTr
kernel_test = computeK(kerneltype, xTe, xTr, kpar)
# # YOUR CODE HERE

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago