Learn R Programming

bmrm (version 4.1)

softmaxLoss: softmax Loss Function

Description

softmax loss function may be used to predict probability distributions

Usage

softmaxLoss(x, y, loss.weights = 1)

Arguments

x

instance matrix, where x(t,) defines the features of instance t

y

target matrix where y(t,) is a probability distribution that should sum to 1

loss.weights

numeric vector of loss weights to incure for each instance of x. Vector length should match nrow(y), but values are recycled if not of identical size.

Value

a function taking one argument w and computing the loss value and the gradient at point w

References

Teo et al. Bundle Methods for Regularized Risk Minimization JMLR 2010

Examples

Run this code
# NOT RUN {
  # -- Load the data
  x <- cbind(intercept=100,data.matrix(iris[1:4]))
  y <- model.matrix(~iris$Species+0)
  w <- nrbm(softmaxLoss(x,y))
  P <- predict(w,x)
  table(max.col(P),iris$Species)
# }

Run the code above in your browser using DataLab