MATLAB Codel APPを使用して、MATLABで記述されたニューラルネットワーク関数をC関数に変換しようとしています。私が変換しようとする。しかし、私はcell2matはMATLAB CoderのCコード生成ではサポートされていません
cell2matとして取得していますが、コード生成arrayfunでサポートされていませんが
がどのように私は、これらの機能を置き換えることができ、コード生成のためにサポートされていませんか?
私のコードは以下の通りです。入力X
は1x2500マトリックスで、output
は1x6マトリックスです。
全コードどのように私は、この機能のためのCコードを生成することができboneGrwNN
function Y = boneGrwNN(X)
x1_step1.ymin = -1;
% ===== SIMULATION ========
% Format Input Arguments
isCellX = iscell(X);
if ~isCellX, X = {X}; end;
% Dimensions
TS = size(X,2); % timesteps
if ~isempty(X)
Q = size(X{1},1); % samples/series
else
Q = 0;
end
% Allocate Outputs
Y = cell(1,TS);
% Time loop
for ts=1:TS
% Input 1
X{1,ts} = X{1,ts}';
Xp1 = mapminmax_apply(X{1,ts},x1_step1);
% Layer 1
a1 = tansig_apply(repmat(b1,1,Q) + IW1_1*Xp1);
% Layer 2
a2 = softmax_apply(repmat(b2,1,Q) + LW2_1*a1);
% Output 1
Y{1,ts} = a2;
Y{1,ts} = Y{1,ts}';
end
% Format Output Arguments
if ~isCellX, Y = cell2mat(Y); end
end
% ===== MODULE FUNCTIONS ========
% Map Minimum and Maximum Input Processing Function
function y = mapminmax_apply(x,settings)
y = bsxfun(@minus,x,settings.xoffset);
y = bsxfun(@times,y,settings.gain);
y = bsxfun(@plus,y,settings.ymin);
end
% Competitive Soft Transfer Function
function a = softmax_apply(n,~)
if isa(n,'gpuArray')
a = iSoftmaxApplyGPU(n);
else
a = iSoftmaxApplyCPU(n);
end
end
function a = iSoftmaxApplyCPU(n)
nmax = max(n,[],1);
n = bsxfun(@minus,n,nmax);
numerator = exp(n);
denominator = sum(numerator,1);
denominator(denominator == 0) = 1;
a = bsxfun(@rdivide,numerator,denominator);
end
function a = iSoftmaxApplyGPU(n)
nmax = max(n,[],1);
numerator = arrayfun(@iSoftmaxApplyGPUHelper1,n,nmax);
denominator = sum(numerator,1);
a = arrayfun(@iSoftmaxApplyGPUHelper2,numerator,denominator);
end
function numerator = iSoftmaxApplyGPUHelper1(n,nmax)
numerator = exp(n - nmax);
end
function a = iSoftmaxApplyGPUHelper2(numerator,denominator)
if (denominator == 0)
a = numerator;
else
a = numerator ./ denominator;
end
end
% Sigmoid Symmetric Transfer Function
function a = tansig_apply(n,~)
a = 2 ./ (1 + exp(-2*n)) - 1;
end
このリンクでaavailableのですか?
'cell2mat'が何をしているのか理解していて、それを渡している入力を理解しているのであれば、なぜ' cell2mat'自体を使わずに手動で動作を複製できないのですか? – Wolfie