[SOLVED] CS gradientDescent<-function(y, X, epsilon=1/10, r=0.1, iters=1000){

$25

File Name: CS_gradientDescent<-function(y,_X,_epsilon=1/10,_r=0.1,_iters=1000){.zip
File Size: 640.56 KB

5/5 - (1 vote)

gradientDescent<-function(y, X, epsilon=1/10, r=0.1, iters=1000){w <- t(as.matrix(rnorm(n=dim(X)[2], mean=0,sd = 1))) # Initialize wN <- dim(X)[1]J <- NULLgrad <- 1while (sqrt(sum(grad^2)) > epsilon) {
J = c(J,1/2*sum((t(y) w%*%t(X))^2))
e = t(y) w%*%t(X)
grad = (2/N)*e%*%X
w = w r*grad
}

print(paste(Final gradient norm is,sqrt(sum(grad^2))))
values<-list(“w” = t(w), “J” = J)return(values)}y <- rnorm(n = 1000, mean = 0, sd = 1)x1 <- rnorm(n = 1000, mean = 0, sd = 1)x2 <- rnorm(n = 1000, mean = 0, sd = 1)sol <- gradientDescent(y = y, X = cbind(x1,x2))

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS gradientDescent<-function(y, X, epsilon=1/10, r=0.1, iters=1000){
$25