Custom Neural network for price forecasting

13 次查看(过去 30 天)
Hello guys, I have attached a custom neural network (made by me) and I would like to do the following:
  1. I want to feed a set of database of 17 inputs provided with some weights and biases followed by a tanh activation function.
  2. It should provide me some suitable outputs(required two) for the next two parallel layers of my neural network as shown in the figure attached (See Network.JPG).
  3. The output provided should be them used to analyse it and give me the two main required output.
How can this be achieved if I use one of my designed network.
Also, I would like to implement a 17(or may be more) inputs with just 2 outputs by a regression neural networking in MATLAB. How can this be achieved? I use trainNetwork command so far to train a 17 inputs to provide me a particular single output for a LSTM regression network. How to modify my network to get just 2 outputs from providing 17 or more number of inputs?
Any help would be great.
Thank you

回答(1 个)

Milan Bansal
Milan Bansal 2023-10-6
Hi Robin Patel,
It is my understanding that you are trying to build a custom Neural Network for multiple output regression.
As per the Neural Network given in attached image, the network can be built by creating a graph of Network layers using "lgraph" function and then creating a "dlnetwork" object which can be trained using custom training loops.
Refer to following code to create a Neural Network according to the attached image.
Create a main branch of the Network.
layers = [featureInputLayer(17,'Name','in') % Input layer for 17 features
fullyConnectedLayer(10) % fully connected layers
tanhLayer('Name','tanh')
fullyConnectedLayer(10,'Name','fc1')
tanhLayer("Name",'tanh1')
fullyConnectedLayer(1,'Name','Out1')
];
Convert it into Layer Graph
lgraph = layerGraph(layers);
Add layers of the second branch to the Layer Graph
lgraph = addLayers(lgraph,[fullyConnectedLayer(10,'Name','fc2'), ...
tanhLayer("Name",'tanh2'), ...
fullyConnectedLayer(1,'Name','Out2')]);
Connect the second branch to the main branch. Then convert the whole Layer Graph into "dlnetwork" object.
lgraph = connectLayers(lgraph,'tanh','fc2');
dlnet = dlnetwork(lgraph);
figure
plot(lgraph)
Refer to the following documentation link to learn more about "layerGraph".
Refer to the following documentation link to learn more about "dlnetwork" object.
Refer to the example in the following documentation link to learn more about Multiple Output Neural Network.
Hope this helps!

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by