[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting the message "warning: implicit conversion from real matrix to re

From: brunoazev
Subject: Getting the message "warning: implicit conversion from real matrix to real scalar"
Date: Tue, 26 Nov 2013 05:18:12 -0800 (PST)

I have done an exercise to Coursera (predict handwritten digits), and
everything seems to be right but I'm getting this warning message and I
don't know why. Althought this message appears, the results are right as you
can see by the image below:


The code that results on that warning is:

function p = predict(Theta1, Theta2, X)
%PREDICT Predict the label of an input given a trained neural network
%   p = PREDICT(Theta1, Theta2, X) outputs the predicted label of X given
%   trained weights of a neural network (Theta1, Theta2)

m = size(X, 1);
num_labels = size(Theta2, 1);
p = zeros(size(X, 1), 1);

*a = sigmoid([ones(m,1) X] * Theta1');

[value,p] = max(sigmoid([ones(size(a),1) a] * Theta2'),[],2);*


However, this works fine:

X = [ones(m, 1) X] ;

for c = 1:num_labels
        X2 = [ones(m, 1) (sigmoid(X * Theta1'))];
        predict(:,c) = sigmoid(X2 * Theta2(c,:)');

[predict, p] = max(predict, [], 2);


My doubt is why I'm getting the warning message in the first solution I

Extra information:

X = 400 input layer units (excluding the extra bias unit which always
outputs +1). 
Theta1 has siz e 25 x 401.
Theta2 has size 10 x 26.

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]