1
$\begingroup$

I'm working on a covid-19 dataset, and I'm interested in using the Artificial Neural Network (ANN) to measure the effect of some independent variables namely: confirmed cases, new cases, and total deaths on the response variable new deaths. The attached is the output using R Kindly explain how to explain this output, it does not look like the normal linear regression I'm familiar with.

enter image description here.

$\endgroup$
  • 4
    $\begingroup$ It does not look like the normal linear regression because it is not a linear regression. If you want to use neural nets you will have to learn, what they are. It will be really hard to answer your question withouht further indication, what knowledge of neural nets you already have so one can built upon that. $\endgroup$ – Bernhard Sep 24 at 12:17
2
$\begingroup$

Black represents the parameter weights.

Blue represents the bias terms (kind of like the intercept in linear regression).

To get the value of a neuron (black circle) towards the right, take the value in the circles to the left, multiply by the weight on the connecting line, and add up those values for all circles pointing towards your circle. We’d typically use a nonlinear activation function, too, such a ReLU, though you have not indicated what you used (if any).

I recommend writing out the full equation of this small neural network, and I hope no one ruins the fun for you before you try to work through it.

EDIT

enter image description here

$g = \text{activation}\big(0.01803 + 2.31748d + 1.00955e - 2.24362f\big)$

Use this to unpack the other six neurons. Then write $g$ in terms of the three predictor variables.

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Use the picture to write down the equation on a sheet of paper. No knowledge of R or any other software is necessary for this. (Well...you’ll have to know the activation functions in each neuron, which you’ll get from your code.) $\endgroup$ – Dave Sep 24 at 11:28
  • 1
    $\begingroup$ Using the package neuralnet the preset activation function will be logistic, unless other options were chosen. $\endgroup$ – Bernhard Sep 24 at 12:14
  • 1
    $\begingroup$ @user2579677 you are missing the effect of the activation functions $\endgroup$ – desertnaut Sep 24 at 14:05
  • 1
    $\begingroup$ @user2579677 You've missed the activation functions and the multiple layers. Take another shot, making use of all 16 numbers in your picture. $\endgroup$ – Dave Sep 24 at 14:20
  • 1
    $\begingroup$ Well I got $g$ by adding up something about the arrows points towards it. Take a shot at writing $d$ by considering the arrows pointing towards it. $\endgroup$ – Dave Oct 1 at 14:13
1
$\begingroup$

Let's simplify your figure and understand at a more generalized level. This neural network has three layers: Input, Hidden and Output. Each layer has multiple neurons whose activations are determined by:

  • Activations of neurons from previous layer
  • Weights and bias

enter image description here

Since this is a fully connected neural network or dense network, there are weights between each neuron between the layers. I have denoted weights by $\theta^{\text{layer number}}_{i, j}$, and bias with $b^{\text{layer number}}_{j}$ where $i$ is the neuron from previous layer and $j$ is the current neuron.

Now coming back to the figure you have provided, here are some example of weights and biases using my notation:

  • $\theta^{2}_{1, 1}=0.35826$
  • $\theta^{2}_{2, 1}=-6.11547$
  • $\theta^{3}_{3, 1}=-2.24362$
  • $b^{2}_{1}=0.85928$
  • $b^{3}_{1}=0.01803$

and so on...

enter image description here

Now that we know what each symbol means let's write some equations to get activation of each neuron. Let's assume a $tanh$ activation function.

Second layer activations can be written as:

$$ h_1 = tanh(\theta^{2}_{1, 1}\:x_1 + \theta^{2}_{2, 1}\:x_2 + \theta^{2}_{3, 1}\:x_3 + b^{2}_{1}) = tanh \bigg( \sum_{i=1:3}\theta^{2}_{i, 1}\:x_i + b^{2}_{1} \bigg) \\ h_2 = tanh \bigg( \sum_{i=1:3}\theta^{2}_{i, 2}\:x_i + b^{2}_{2} \bigg) \\ h_3 = tanh \bigg( \sum_{i=1:3}\theta^{3}_{i, 2}\:x_i + b^{2}_{3} \bigg) $$

And finally the output layer activations can be written as:

$$ y = tanh \bigg( \sum_{i=1:3}\theta^{3}_{i, 1}\:h_i + b^{3}_{1} \bigg) $$

| cite | improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.