train_MBGD: Using Mini-Batch Gradient Descent to train the model.

Description Usage Arguments Value Examples

View source: R/StatComp21088R.R

Description

Use Mini-Batch Gradient Descent to train the model.

Usage

1
train_MBGD(input_data, real_result, iter, batch_size, alpha, theta)

Arguments

input_data

Input_data matrix after adding constant 1 column

real_result

Real_result vector whose length is equal to the column number of data.

iter

iterations

batch_size

Batch_size parameter constant

alpha

Learning rate

theta

The initial parameters of linear regression

Value

theta after iterations and cost after every training (theta ,cost)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
x <- seq(0.1,10,0.01)
n <- length(x)
z <- rnorm(n)
y <- 2*x+5+z
mbgd <- train_MBGD(x,y,200,0.01,c(1,1))$theta
print(mbgd$theta)
print(mbgd$cost)

## End(Not run)

Sakoylf/StatComp21088 documentation built on Dec. 23, 2021, 10:22 p.m.