matlab RANDS函数的问题

来源:百度知道 编辑:UC知道 时间:2024/06/18 17:53:14
[a,b]=rands(2,2)
a =

-0.4205 0.0682
-0.3176 0.4542

b =

-0.3814
0.6770

为什么a b 矩阵列数不同呢,希望高手详细解答,万分感谢。

这个问题和神经元算法实现有关。
你看一下程序的源代码,注意看最下下面标出的那两行:

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 init