A Factors that determine the optimal non-linear decoder, g(⋅). For any particular filter set, the optimal decoder provides a closed form expression for the cost by i) computing the posterior probability over the latent variable p(X|R), and ii) reading out the optimal estimate from the posterior that minimizes the cost. B AMA begins with a labeled training set. Each individual stimulus in the training set, sij, must be labeled with a particular value of the latent variable of interest, Xi. The labeling of the training set implicitly defines the task. Subsequent steps to finding optimal task-specific filters via AMA are: i) select a particular stimulus skl from the labeled training set; ii) obtain a noisy filter response Rkl from a given (possibly non-optimal) set of initial filters; iii) use the optimal non-linear decoder to obtain the optimal estimate and its expected cost; iv) repeat for each stimulus in the training set and compute the average cost across the training set; v) update the filters to reduce the cost; vi) repeat until the average cost across the training set is minimized. The filters that minimize the cost are the optimal task-specific filters.