Main Content

setwb

Set all network weight and bias values with single vector

Syntax

net = setwb(net,wb)

Description

This function sets a network’s weight and biases to a vector of values.

net = setwb(net,wb) takes the following inputs:

net

Neural network

wb

Vector of weight and bias values

Examples

Set Network's Weights and Biases

This example shows how to set and view a network’s weight and bias values.

Create and configure a network.

[x,t] = simplefit_dataset;
net = feedforwardnet(3);
net = configure(net,x,t);
view(net)

This network has three weights and three biases in the first layer, and three weights and one bias in the second layer. So, the total number of weight and bias values in the network is 10. Set the weights and biases to random values.

net = setwb(net,rand(10,1));

View the weight and bias values

net.IW{1,1}
net.b{1}
ans =

    0.1576
    0.9706
    0.9572


ans =

    0.5469
    0.9575
    0.9649

Version History

Introduced in R2010b

See Also

| |