https://github.com/axect/pytorch_derivative_test
https://github.com/axect/pytorch_derivative_test
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/axect/pytorch_derivative_test
- Owner: Axect
- License: mit
- Created: 2024-06-11T00:49:02.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-11T02:00:00.000Z (12 months ago)
- Last Synced: 2025-03-28T19:46:35.687Z (2 months ago)
- Language: Python
- Size: 1.65 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyTorch Derivative Test
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.
## Installation
To use this project, you can easily set up the same environment using [`uv`](https://github.com/astral-sh/uv):
```bash
# Create virtual env
uv venv# Sync
uv pip sync requirements.txt# Activate
source .venv/bin/activate
```This command will install all the required dependencies specified in the `requirements.txt` file.
Alternatively, you can use `pip` to install the dependencies:
```bash
pip install -r requirements.txt
```## Usage
To run the project, simply execute the `equation_net.py` script:
```bash
python equation_net.py
```The script will generate random data, train the neural network, and plot the learned functions and derivatives along with the true functions and derivatives.
## Results
The project generates two plots:
1. Output and derivatives with respect to x (y=0):

2. 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.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.