[W1,B1]=rands(2,2)
??? Error using ==> rands
Too many output arguments.
这个是怎么回事呢
matlab rands函数问题
答案:2 悬赏:20 手机版
解决时间 2021-01-27 10:25
- 提问者网友:不要迷恋哥
- 2021-01-26 12:24
最佳答案
- 五星知识达人网友:执傲
- 2021-01-26 13:59
只能返回一个参数
全部回答
- 1楼网友:鱼忧
- 2021-01-26 14:25
这个问题和神经元算法实现有关。
你看一下程序的源代码,注意看最下下面标出的那两行:
function [w,b] = rands(s,pr)
%rands symmetric random weight/bias initialization function.
%
% syntax
%
% w = rands(s,pr)
% m = rands(s,r)
% v = rands(s);
%
% description
%
% rands is a weight/bias initialization function.
%
% rands(s,pr) takes,
% s - number of neurons.
% pr - rx2 matrix of r input ranges.
% and returns an s-by-r weight matrix of random values between -1 and 1.
%
% rands(s,r) returns an s-by-r matrix of random values.
% rands(s) returns an s-by-1 vector of random values.
%
% examples
%
% here three sets of random values are generated with rands.
%
% rands(4,[0 1; -2 2])
% rands(4)
% rands(2,3)
%
% network use
%
% to prepare the weights and the bias of layer i of a custom network
% to be initialized with rands:
% 1) set net.initfcn to 'initlay'.
% (net.initparam will automatically become initlay's default parameters.)
% 2) set net.layers{i}.initfcn to 'initwb'.
% 3) set each net.inputweights{i,j}.initfcn to 'rands'.
% set each net.layerweights{i,j}.initfcn to 'rands';
% set each net.biases{i}.initfcn to 'rands'.
%
% to initialize the network call init.
%
% see also randnr, randnc, initwb, initlay, init
% mark beale, 1-31-92
% revised 12-15-93, mb
% revised 11-31-97, mb
% copyright 1992-2008 the mathworks, inc.
% $revision: 1.1.6.7 $ $date: 2008/06/20 08:04:33 $
fn = mfilename;
if (nargin < 1), error('nnet:arguments','not enough arguments.'); end
if ischar(s)
switch(s)
case 'name'
w = 'midpoint';
otherwise, error('nnet:arguments',['unrecognized code: ''' s ''''])
end
return
end
if nargin == 1
r = 1;
elseif size(pr,2) == 1
r = pr;
else
r = size(pr,1);
end
w = 2*rand(s,r)-1;//看着个地方
% **[ nnt2 support ]**
if nargout == 2
b = 2*rand(s,1)-1; //看着个地方
end])
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯