Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train linear combinations of inputs #88

Merged
merged 5 commits into from
Sep 24, 2023
Merged

Train linear combinations of inputs #88

merged 5 commits into from
Sep 24, 2023

Conversation

rouson
Copy link
Contributor

@rouson rouson commented Sep 24, 2023

This pull request adds example/fit-polynomials.f90, which trains a neural network to learn linear combinations of the inputs. The neural network learns to map eight inputs, x(1:8), to six outputs corresponding to y(x) = [x(1), x(2) + x(3), x(4), x(5), 0.5*x(6) + 1.5*x(7), x(8)], where the network uses

  • The ReLU activation function,
  • The Adam optimizer,
  • An initial condition corresponding to a randomly perturbed identity mapping of the six middle inputs, i..e. y(x) = [x(2), x(3), x(4), x(5), x(6), x(7), and
  • Two hidden layers with 8 nodes each.

The program example/train_and_write.f90 now demonstrates how to
train a simple neural network starting from a randomized initial
condition and how to write the initial network and the trained
network to separate JSON files, where the network has

 - 2 hidden layers,
 - 2 nodes per layer for the input, hidden, and output layers, and
 - desired outputs identically matching the corresponding inputs.

With ReLU activation functions, the desired network therefore
contains weights corresponding to identity matrices and biases
that vanish everywhere.  The initial condition is the desired
network with all weights and biases perturbed by a random variable
that is uniformly distributed on the interval [0,0.1].
@rouson rouson merged commit 8b0f2b1 into main Sep 24, 2023
4 checks passed
@rouson rouson deleted the update-example branch September 24, 2023 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant