Skip to content

Commit

Permalink
test cuda device
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziming Liu committed Apr 27, 2024
1 parent e15cc47 commit 5ac3a58
Show file tree
Hide file tree
Showing 43 changed files with 375 additions and 21 deletions.
16 changes: 16 additions & 0 deletions docs/.ipynb_checkpoints/demos-checkpoint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API Demos
---------

.. toctree::
:maxdepth: 1

API_demo/API_1_indexing.rst
API_demo/API_2_plotting.rst
API_demo/API_3_grid.rst
API_demo/API_4_extract_activations.rst
API_demo/API_5_initialization_hyperparameter.rst
API_demo/API_6_training_hyperparameter.rst
API_demo/API_7_pruning.rst
API_demo/API_8_checkpoint.rst
API_demo/API_9_video.rst
API_demo/API_10_device.rst
46 changes: 46 additions & 0 deletions docs/.ipynb_checkpoints/index-checkpoint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. kolmogorov-arnold-network documentation master file, created by
sphinx-quickstart on Sun Apr 21 12:57:28 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Kolmogorov Aarnold Network (KAN) documentation!
==========================================================

This documentation is for the paper "KAN: Kolmogorov-Arnold Networks" and the github repo can be found here.

.. image:: kan_plot.png

Get the latest news at `CNN`_. (Add links to paper and github repo)

.. _CNN: http://cnn.com/

There are two ways to install kan. The first way is via pip install

.. code-block:: python
pip install kan
The second way is via github

.. code-block:: python
git clone repolink
cd kan
pip install -e .
.. toctree::
:maxdepth: 1
:caption: Contents:

intro.rst
modules.rst
demos.rst
examples.rst

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
12 changes: 6 additions & 6 deletions docs/.ipynb_checkpoints/intro-checkpoint.ipynb

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions docs/API_demo/.ipynb_checkpoints/API_10_device-checkpoint.ipynb

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions docs/API_demo/API_10_device.ipynb

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions docs/API_demo/API_10_device.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Demo 10: Device
===============

All other demos have by default used device = ‘cpu’. In case we want to
use cuda, we should pass the device argument to model and dataset.

.. code:: ipython3
from kan import KAN, create_dataset
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print(device)
.. parsed-literal::
cuda
.. code:: ipython3
model = KAN(width=[4,2,1,1], grid=3, k=3, seed=0, device=device)
f = lambda x: torch.exp((torch.sin(torch.pi*(x[:,[0]]**2+x[:,[1]]**2))+torch.sin(torch.pi*(x[:,[2]]**2+x[:,[3]]**2)))/2)
dataset = create_dataset(f, n_var=4, train_num=3000, device=device)
# train the model
#model.train(dataset, opt="LBFGS", steps=20, lamb=1e-3, lamb_entropy=2.);
model.train(dataset, opt="LBFGS", steps=50, lamb=5e-5, lamb_entropy=2.);
.. parsed-literal::
train loss: 6.70e-03 | test loss: 6.83e-03 | reg: 7.91e+00 : 100%|██| 50/50 [00:25<00:00, 1.99it/s]
.. code:: ipython3
model.plot()
.. image:: API_10_device_files/API_10_device_3_0.png


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_0_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_0_0_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_0_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_0_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/API_demo/figures/sp_0_2_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/API_demo/figures/sp_0_2_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/API_demo/figures/sp_0_3_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/API_demo/figures/sp_0_3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_1_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_1_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/API_demo/figures/sp_2_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train loss: 1.54e-02 | test loss: 1.50e-02 | reg: 3.01e+00 : 100%|██| 20/20 [00:03<00:00, 6.45it/s]\n"
"train loss: 1.54e-02 | test loss: 1.50e-02 | reg: 3.06e+00 : 100%|██| 20/20 [00:06<00:00, 2.91it/s]\n"
]
}
],
Expand Down Expand Up @@ -100,7 +100,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train loss: 3.18e-04 | test loss: 3.29e-04 | reg: 3.00e+00 : 100%|██| 20/20 [00:02<00:00, 6.87it/s]\n"
"train loss: 3.10e-04 | test loss: 3.22e-04 | reg: 3.03e+00 : 100%|██| 20/20 [00:07<00:00, 2.67it/s]\n"
]
}
],
Expand Down Expand Up @@ -253,7 +253,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5412,7 +5412,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions docs/Examples/Example_1_function_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train loss: 1.54e-02 | test loss: 1.50e-02 | reg: 3.01e+00 : 100%|██| 20/20 [00:03<00:00, 6.45it/s]\n"
"train loss: 1.54e-02 | test loss: 1.50e-02 | reg: 3.06e+00 : 100%|██| 20/20 [00:06<00:00, 2.91it/s]\n"
]
}
],
Expand Down Expand Up @@ -100,7 +100,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train loss: 3.18e-04 | test loss: 3.29e-04 | reg: 3.00e+00 : 100%|██| 20/20 [00:02<00:00, 6.87it/s]\n"
"train loss: 3.10e-04 | test loss: 3.22e-04 | reg: 3.03e+00 : 100%|██| 20/20 [00:07<00:00, 2.67it/s]\n"
]
}
],
Expand Down Expand Up @@ -253,7 +253,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/Example_4_symbolic_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5412,7 +5412,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion docs/demos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ API Demos
API_demo/API_6_training_hyperparameter.rst
API_demo/API_7_pruning.rst
API_demo/API_8_checkpoint.rst
API_demo/API_9_video.rst
API_demo/API_9_video.rst
API_demo/API_10_device.rst
Binary file modified docs/figures/sp_0_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_0_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_0_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_0_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_0_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_1_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_0_1_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_1_0_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_1_1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_1_2_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/figures/sp_1_3_0.png
Binary file modified docs/figures/sp_1_4_0.png
12 changes: 6 additions & 6 deletions docs/intro.ipynb

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions pykan.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Metadata-Version: 2.1
Name: pykan
Version: 0.0.1
Summary: Kolmogorov Arnold Networks
Author: Ziming Liu
Author-email: [email protected]
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
13 changes: 13 additions & 0 deletions pykan.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
README.md
setup.py
kan/KAN.py
kan/KANLayer.py
kan/LBFGS.py
kan/Symbolic_KANLayer.py
kan/__init__.py
kan/spline.py
kan/utils.py
pykan.egg-info/PKG-INFO
pykan.egg-info/SOURCES.txt
pykan.egg-info/dependency_links.txt
pykan.egg-info/top_level.txt
1 change: 1 addition & 0 deletions pykan.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions pykan.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kan

0 comments on commit 5ac3a58

Please sign in to comment.