1
我很難將我的製表符分隔的輸入文件加載到MATLAB nprtool中,我認爲這是因爲nprtool GUI不支持加載混合數據類型。我加載在.tab文件具有大致1100的數據樣本(行),其中的每一個看起來像:將混合數據類型加載到MATLAB神經網絡工具箱
864 1342470776.212023000 172.25.177.41 155.34.234.20 HTTP 440 58689 http-alt GET http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/hdr-main.gif image/png,image/*;q=0.8,*/*;q=0.5 gzip,deflate 0.000094000 http://www.cnn.com/
上面只是在輸入向量的單個樣品。我嘗試使用nprtool GUI加載文件,但它無法正確識別數據。它將這一切視爲'textdata'與'data'部分中的一些垃圾。然後我嘗試通過腳本在沒有GUI的情況下做到這一點。這個方法拋出一個錯誤(如下)。任何方式在這個?以下是我用來加載文件和錯誤的腳本片段。任何幫助表示讚賞。謝謝!
text1 = fopen('/Users/cgarry/Desktop/CRANEUM/output.tab');
pacTargets = importdata('/Users/cgarry/Desktop/CRANEUM/data.tab','\t');
pacInputs = textscan(text1,'%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s');
fclose(text1);
inputs = pacInputs;
targets = pacTargets;
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, plotconfusion(targets,outputs)
%figure, ploterrhist(errors)
>> nnet
Error using trainscg (line 97)
Inputs X{1,1} is not numeric or logical.
Error in network/train (line 106)
[net,tr] = feval(net.trainFcn,net,X,T,Xi,Ai,EW,net.trainParam);
Error in nnet (line 21)
[net,tr] = train(net,inputs,targets);