sigmf doesnt' work in octave ?
5 ビュー (過去 30 日間)
古いコメントを表示
hello l get this error when l execute this code :
error: 'sigmf' undefined near line 29 column 28
and sigmf is predefined in octave and matlab as it is mentionned in octave and matlab documentation
% load training set and testing set
clear all;
train_set = loadMNISTImages('/home/anelmad/my_codes/MNIST_digit_recognition-master/load_data/train-images.idx3-ubyte');
train_label = loadMNISTLabels('/home/anelmad/my_codes/MNIST_digit_recognition-master/load_data/train-labels.idx1-ubyte');
test_set = loadMNISTImages('/home/anelmad/my_codes/MNIST_digit_recognition-master/load_data/t10k-images.idx3-ubyte');
test_label = loadMNISTLabels('/home/anelmad/my_codes/MNIST_digit_recognition-master/load_data/t10k-labels.idx1-ubyte');
% parameter setting
alpha = 0.1; % learning rate
beta = 0.01; % scaling factor for sigmoid function
train_size = size(train_set);
N = train_size(1); % number of training samples
D = train_size(2); % dimension of feature vector
n_hidden = 300; % number of hidden layer units
K = 10; % number of output layer units
% initialize all weights between -1 and 1
W1 = 2*rand(1+D, n_hidden)-1; % weight matrix from input layer to hidden layer
W2 = 2*rand(1+n_hidden, K)-1; % weight matrix from hidden layer to ouput layer
max_iter = 100; % number of iterations
Y = eye(K); % output vector
% training
for i=1:max_iter
disp([num2str(i), ' iteration']);
for j=1:N
% propagate the input forward through the network
input_x = [1; train_set(j, :)'];
hidden_output = [1;sigmf(W1'*input_x, [beta 0])];
output = sigmf(W2'*hidden_output, [beta 0]);
% propagate the error backward through the network
% compute the error of output unit c
delta_c = (output-Y(:,train_label(j)+1)).*output.*(1-output);
% compute the error of hidden unit h
delta_h = (W2*delta_c).*(hidden_output).*(1-hidden_output);
delta_h = delta_h(2:end);
% update weight matrix
W1 = W1 - alpha*(input_x*delta_h');
W2 = W2 - alpha*(hidden_output*delta_c');
end
end
% testing
test_size = size(test_set);
num_correct = 0;
for i=1:test_size(1)
input_x = [1; test_set(i,:)'];
hidden_output = [1; sigmf(W1'*input_x, [beta 0])];
output = sigmf(W2'*hidden_output, [beta 0]);
[max_unit, max_idx] = max(output);
if(max_idx == test_label(i)+1)
num_correct = num_correct + 1;
end
end
% computing accuracy
accuracy = num_correct/test_size(1);
or l have to define sigmf ?
Thanks for helps
4 件のコメント
回答 (1 件)
Walter Roberson
2016 年 3 月 7 日
If you do not have that toolbox you might be able to substitute http://www.mathworks.com/matlabcentral/fileexchange/47204-fuzzy-model-identification-for-control/content/E5_2_IMC_Liq/sigmf.m
5 件のコメント
Walter Roberson
2016 年 3 月 14 日
The Mathworks Fuzzy Logic Toolbox cannot be used with Octave, not within the terms of the license agreement.
There is an open source Octave Fuzzy Logic Toolkit. If that is what you are using, you should be asking the author or asking in an Octave resource; this forum is a MATLAB resource and Octave is off-topic here.
参考
カテゴリ
Help Center および File Exchange で Fuzzy Logic Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!