This project aims to verify whether derivatives are well-trained when training a neural network using PyTorch. By comparing the learned derivatives with the true derivatives, we can assess the effectiveness of the training process.
To use this project, you can easily set up the same environment using uv:
# Create virtual env
uv venv
# Sync
uv pip sync requirements.txt
# Activate
source .venv/bin/activateThis command will install all the required dependencies specified in the requirements.txt file.
Alternatively, you can use pip to install the dependencies:
pip install -r requirements.txtTo run the project, simply execute the equation_net.py script:
python equation_net.pyThe script will generate random data, train the neural network, and plot the learned functions and derivatives along with the true functions and derivatives.
The project generates two plots:
- Output and derivatives with respect to x (y=0):
- Output and derivatives with respect to y (x=0):
The solid lines represent the learned functions and derivatives, while the dotted lines represent the true functions and derivatives. By comparing the solid and dotted lines, you can assess how well the neural network has learned the functions and their derivatives.
This project is licensed under the MIT License. See the LICENSE file for more information.

