Main Content

rands

Symmetric random weight/bias initialization function

Syntax

W = rands(S,PR)
M = rands(S,R)
v = rands(S)

Description

randsis a weight/bias initialization function.

W = rands(S,PR)takes

S

Number of neurons

公关

R-by-2matrix ofRinput ranges

并返回一个S-by-Rweight matrix of random values between –1 and 1.

M = rands(S,R)returns anS-by-Rmatrix of random values.v = rands(S)returns anS-by-1 vector of random values.

Examples

Here, three sets of random values are generated withrands.

rands(4,[0 1; -2 2]) rands(4) rands(2,3)

Network Use

To prepare the weights and the bias of layeriof a custom network to be initialized withrands,

  1. Setnet.initFcnto'initlay'. (net.initParamautomatically becomesinitlay’s default parameters.)

  2. Setnet.layers{i}.initFcnto'initwb'.

  3. Set eachnet.inputWeights{i,j}.initFcnto'rands'.

  4. Set eachnet.layerWeights{i,j}.initFcnto'rands'.

  5. Set eachnet.biases{i}.initFcnto'rands'.

To initialize the network, callinit.

Version History

Introduced before R2006a