--- a +++ b/combinedDeepLearningActiveContour/functions/mrPredict.m @@ -0,0 +1,33 @@ +function [pred] = mrPredict(mrModel, data) + +% mrModel - model trained using mrTrain +% data - the N x M input matrix, where each column data(:, i) corresponds to +% a single test set +% +% Your code should produce the prediction matrix +% pred, where pred(i) is argmax_c P(y(c) | x(i)). + +% Unroll the parameters from theta +theta = mrModel.optTheta; % this provides a numClasses x inputSize matrix +pred = zeros(1, size(data, 2)); + +%% ---------- YOUR CODE HERE -------------------------------------- +% Instructions: Compute pred using theta assuming that the labels start +% from 1. +z=theta*data; +pred=sigmoid(z)>.5; + + +% --------------------------------------------------------------------- + +end + + +%------------------------------------------------------------------- +% Here's an implementation of the sigmoid function, which you may find useful +% in your computation of the costs and the gradients. This inputs a (row or +% column) vector (say (z1, z2, z3)) and returns (f(z1), f(z2), f(z3)). + +function sigm = sigmoid(x) + sigm = 1 ./ (1 + exp(-x)); +end