Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
cp -a $GITHUB_WORKSPACE /home/gap/.gap/pkg/
- name: Prepare environment
run: |
cp ./GradientDescentForCAP/dev/ci_gaprc /home/gap/.gap/gaprc
git clone --depth 1 -vv https://github.com/gap-packages/AutoDoc.git
cp ./GradientBasedLearningForCAP/dev/ci_gaprc /home/gap/.gap/gaprc
git clone --depth 1 -vv https://github.com/homalg-project/homalg_project.git
git clone --depth 1 -vv https://github.com/homalg-project/CAP_project.git
git clone --depth 1 -vv https://github.com/homalg-project/CategoricalTowers.git
Expand All @@ -59,18 +58,20 @@ jobs:
if [ -d "CAP_project/CompilerForCAP" ]; then make -C "CAP_project/CompilerForCAP" doc; fi
if [ -d "CAP_project/MonoidalCategories" ]; then make -C "CAP_project/MonoidalCategories" doc; fi
if [ -d "CAP_project/CartesianCategories" ]; then make -C "CAP_project/CartesianCategories" doc; fi
if [ -d "CAP_project/AdditiveClosuresForCAP" ]; then make -C "CAP_project/AdditiveClosuresForCAP" doc; fi
if [ -d "CAP_project/FreydCategoriesForCAP" ]; then make -C "CAP_project/FreydCategoriesForCAP" doc; fi
if [ -d "HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra" ]; then make -C "HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra" doc; fi
if [ -d "homalg_project/homalg" ]; then make -C "homalg_project/homalg" doc; fi
if [ -d "homalg_project/Modules" ]; then make -C "homalg_project/Modules" doc; fi
if [ -d "CategoricalTowers/ToolsForCategoricalTowers" ]; then make -C "CategoricalTowers/ToolsForCategoricalTowers" doc; fi
if [ -d "CategoricalTowers/Toposes" ]; then make -C "CategoricalTowers/Toposes" doc; fi
- name: Test GradientDescentForCAP
if [ -d "GradientBasedLearningForCAP" ]; then make -C "GradientBasedLearningForCAP" doc; fi
- name: Test GradientBasedLearningForCAP
run: |
make -C GradientDescentForCAP --trace -j $(nproc) --output-sync ci-test
make -C GradientBasedLearningForCAP --trace -j $(nproc) --output-sync ci-test
- name: Release package or simulate release
run: |
cd GradientDescentForCAP
cd GradientBasedLearningForCAP
python3 dev/process_coverage.py
git config --global user.name "Bot"
git config --global user.email "empty"
Expand All @@ -88,5 +89,5 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
cd GradientDescentForCAP
cd GradientBasedLearningForCAP
./dev/upload_codecov.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
/doc/*.xml
/doc_tmp/
/stats
/tst/machinelearningforcap*.tst
/tst/gradientbasedlearningforcap*.tst
24 changes: 12 additions & 12 deletions PackageInfo.g
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# GradientDescentForCAP: Exploring categorical machine learning in CAP
# GradientBasedLearningForCAP: Gradient Based Learning via Category Theory
#
# This file contains package meta data. For additional information on
# the meaning and correct usage of these fields, please consult the
Expand All @@ -8,9 +8,9 @@
#
SetPackageInfo( rec(

PackageName := "GradientDescentForCAP",
Subtitle := "Exploring categorical machine learning in CAP",
Version := "2025.11-01",
PackageName := "GradientBasedLearningForCAP",
Subtitle := "Gradient Based Learning via Category Theory",
Version := "2026.01-01",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand All @@ -34,13 +34,13 @@ Persons := [
# BEGIN URLS
SourceRepository := rec(
Type := "git",
URL := "https://github.com/homalg-project/GradientDescentForCAP",
URL := "https://github.com/homalg-project/GradientBasedLearningForCAP",
),
IssueTrackerURL := Concatenation( ~.SourceRepository.URL, "/issues" ),
PackageWWWHome := "https://homalg-project.github.io/pkg/GradientDescentForCAP",
PackageInfoURL := "https://homalg-project.github.io/GradientDescentForCAP/PackageInfo.g",
README_URL := "https://homalg-project.github.io/GradientDescentForCAP/README.md",
ArchiveURL := Concatenation( "https://github.com/homalg-project/GradientDescentForCAP/releases/download/v", ~.Version, "/GradientDescentForCAP-", ~.Version ),
PackageWWWHome := "https://homalg-project.github.io/pkg/GradientBasedLearningForCAP",
PackageInfoURL := "https://homalg-project.github.io/GradientBasedLearningForCAP/PackageInfo.g",
README_URL := "https://homalg-project.github.io/GradientBasedLearningForCAP/README.md",
ArchiveURL := Concatenation( "https://github.com/homalg-project/GradientBasedLearningForCAP/releases/download/v", ~.Version, "/GradientBasedLearningForCAP-", ~.Version ),
# END URLS

ArchiveFormats := ".tar.gz .zip",
Expand All @@ -58,16 +58,16 @@ Status := "dev",
AbstractHTML := "",

PackageDoc := rec(
BookName := "GradientDescentForCAP",
BookName := "GradientBasedLearningForCAP",
ArchiveURLSubset := ["doc"],
HTMLStart := "doc/chap0.html",
PDFFile := "doc/manual.pdf",
SixFile := "doc/manual.six",
LongTitle := "Exploring categorical machine learning in CAP",
LongTitle := "Gradient Based Learning via Category Theory",
),

Dependencies := rec(
GAP := ">= 4.15.1",
GAP := ">= 4.13.0",
NeededOtherPackages := [
[ "GAPDoc", ">= 1.5" ],
[ "CAP", ">= 2024.09-12" ],
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- BEGIN HEADER -->
# GradientDescentForCAP&ensp;<sup><sup>[![View code][code-img]][code-url]</sup></sup>
# GradientBasedLearningForCAP&ensp;<sup><sup>[![View code][code-img]][code-url]</sup></sup>

### Exploring categorical machine learning in CAP
### Gradient Based Learning via Category Theory

| Documentation | Latest Release | Build Status | Code Coverage |
| ------------- | -------------- | ------------ | ------------- |
Expand All @@ -22,25 +22,25 @@ To obtain current versions of all dependencies, `git clone` (or `git pull` to up
| 3. | [**CategoricalTowers**](https://github.com/homalg-project/CategoricalTowers#readme) | https://github.com/homalg-project/CategoricalTowers.git |

[html-img]: https://img.shields.io/badge/🔗%20HTML-stable-blue.svg
[html-url]: https://homalg-project.github.io/GradientDescentForCAP/doc/chap0_mj.html
[html-url]: https://homalg-project.github.io/GradientBasedLearningForCAP/doc/chap0_mj.html

[pdf-img]: https://img.shields.io/badge/🔗%20PDF-stable-blue.svg
[pdf-url]: https://homalg-project.github.io/GradientDescentForCAP/download_pdf.html
[pdf-url]: https://homalg-project.github.io/GradientBasedLearningForCAP/download_pdf.html

[version-img]: https://img.shields.io/endpoint?url=https://homalg-project.github.io/GradientDescentForCAP/badge_version.json&label=🔗%20version&color=yellow
[version-url]: https://homalg-project.github.io/GradientDescentForCAP/view_release.html
[version-img]: https://img.shields.io/endpoint?url=https://homalg-project.github.io/GradientBasedLearningForCAP/badge_version.json&label=🔗%20version&color=yellow
[version-url]: https://homalg-project.github.io/GradientBasedLearningForCAP/view_release.html

[date-img]: https://img.shields.io/endpoint?url=https://homalg-project.github.io/GradientDescentForCAP/badge_date.json&label=🔗%20released%20on&color=yellow
[date-url]: https://homalg-project.github.io/GradientDescentForCAP/view_release.html
[date-img]: https://img.shields.io/endpoint?url=https://homalg-project.github.io/GradientBasedLearningForCAP/badge_date.json&label=🔗%20released%20on&color=yellow
[date-url]: https://homalg-project.github.io/GradientBasedLearningForCAP/view_release.html

[tests-img]: https://github.com/homalg-project/GradientDescentForCAP/actions/workflows/Tests.yml/badge.svg?branch=master
[tests-url]: https://github.com/homalg-project/GradientDescentForCAP/actions/workflows/Tests.yml?query=branch%3Amaster
[tests-img]: https://github.com/homalg-project/GradientBasedLearningForCAP/actions/workflows/Tests.yml/badge.svg?branch=master
[tests-url]: https://github.com/homalg-project/GradientBasedLearningForCAP/actions/workflows/Tests.yml?query=branch%3Amaster

[codecov-img]: https://codecov.io/gh/homalg-project/GradientDescentForCAP/branch/master/graph/badge.svg
[codecov-url]: https://app.codecov.io/gh/homalg-project/GradientDescentForCAP
[codecov-img]: https://codecov.io/gh/homalg-project/GradientBasedLearningForCAP/branch/master/graph/badge.svg
[codecov-url]: https://app.codecov.io/gh/homalg-project/GradientBasedLearningForCAP

[code-img]: https://img.shields.io/badge/-View%20code-blue?logo=github
[code-url]: https://github.com/homalg-project/GradientDescentForCAP#top
[code-url]: https://github.com/homalg-project/GradientBasedLearningForCAP#top
<!-- END FOOTER -->

### Running the Package with Docker
Expand Down Expand Up @@ -93,7 +93,7 @@ In this example, we consider a training dataset consisting of the three points

We aim to compute a line that fits $\mathcal{D}$.
```julia
gap> LoadPackage( "GradientDescentForCAP" );
gap> LoadPackage( "GradientBasedLearningForCAP" );
true

gap> Para := CategoryOfParametrisedMorphisms( SkeletalSmoothMaps );
Expand Down Expand Up @@ -288,7 +288,7 @@ To facilitate this classification, we use a one-hot encoding scheme for the labe
That is, the training set (the set of labeled exmaples) is a finite subset of $\mathbb{R}^2 \times \mathbb{R}^3 \simeq \mathbb{R}^5$.

```julia
gap> LoadPackage( "GradientDescentForCAP" );
gap> LoadPackage( "GradientBasedLearningForCAP" );
true

gap> Para := CategoryOfParametrisedMorphisms( SkeletalSmoothMaps );
Expand Down
2 changes: 1 addition & 1 deletion dev/.release
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sed "s;Date := .*;Date := \"$(date -I)\",;" PackageInfo.g > PackageInfo.g.bak
mv PackageInfo.g.bak PackageInfo.g

# replace links to packages which are possibly referenced in the documentation, keep this in sync with `Tests.yml.j2`
for package in CAP_project/CAP CAP_project/CompilerForCAP CAP_project/MonoidalCategories CAP_project/CartesianCategories CAP_project/FreydCategoriesForCAP HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra homalg_project/homalg homalg_project/Modules CategoricalTowers/ToolsForCategoricalTowers CategoricalTowers/Toposes; do
for package in CAP_project/CAP CAP_project/CompilerForCAP CAP_project/MonoidalCategories CAP_project/CartesianCategories CAP_project/AdditiveClosuresForCAP CAP_project/FreydCategoriesForCAP HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra homalg_project/homalg homalg_project/Modules CategoricalTowers/ToolsForCategoricalTowers CategoricalTowers/Toposes GradientBasedLearningForCAP; do

# adjust links to other manuals
# Note that we cannot use sed's `-i` option for in-place editing, as
Expand Down
11 changes: 9 additions & 2 deletions dev/upload_codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ curl -O https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM

# read the token
if [ -z "$CODECOV_TOKEN" ]; then
echo -e "\033[0;33mCODECOV_TOKEN is not set. Proceeding without token.\033[0m"
else
echo -e "\033[0;32mUsing CODECOV_TOKEN from environment variable.\033[0m"
fi

# execute
chmod +x codecov
while ! ./codecov -Z -v -s ../ -t $CODECOV_TOKEN; do
echo "Codecov upload failed, retrying in 20s"
sleep 20
echo "Codecov upload failed, retrying in 60s"
sleep 60
done
102 changes: 101 additions & 1 deletion doc/Doc.autodoc
Original file line number Diff line number Diff line change
@@ -1 +1,101 @@
@Chapter Examples and Tests
@Chapter Introduction

This package provides tools for exploring categorical machine learning using the CAP (Categories, Algorithms, Programming) system.
It implements automatic differentiation using the lens pattern and provides constructs for building and training neural networks.

@Section Overview

The package implements the following main concepts:

* **Examples**: Examples for creating and training neural networks.

* **Expressions**: A symbolic expression system for representing mathematical formulas.

* **Skeletal Category of Smooth Maps**: A category where objects are Euclidean spaces $\mathbb{R}^n$ and morphisms are smooth maps with their Jacobian matrices.

* **Category of Parametrised Morphisms**: A category that represents morphisms with learnable parameters, used to model neural network layers.

* **Neural Networks**: High-level operations for constructing and training neural networks.

* **Category of Lenses**: A category that models bidirectional data flow, essential for backpropagation in neural networks.

* **Fitting Parameters**: Explain how to learn the parameters in order to minimize a parametrised morphism.

* **CAP Operation**: The new categorical operations needed in this package.

* **Tools**: Few GAP operations and helper functions.


@Chapter Examples for neural networks

@Section Binary-class neural network with binary cross-entropy loss function
@Section Multi-class neural network with cross-entropy loss function
@Section Neural network with quadratic loss function

@Chapter Expressions

@Section Constructors
@Section Attributes
@Section Operations
@Section Global Functions
@Section Examples
@Section GAP Categories

@Chapter Skeletal Category of Smooth Maps

@Section Constructors
@Section Attributes
@Section Operations
@Section Available Smooth Maps
@Section Supported CAP Operations
@Section Examples
@Section GAP Categories

@Chapter Category of Parametrised Morphisms

@Section Definition
@Section Constructors
@Section Attributes
@Section Operations
@Section Available Parametrised Morphisms
@Section Supported CAP Operations
@Section Examples
@Section GAP Categories

@Chapter Neural Networks

@Section Definition
@Section Operations
@Section Examples

@Chapter Category of Lenses

@Section Definition
@Section Constructors
@Section Attributes
@Section Operations
@Section Available Lenses
@Section Optimizers
@Section Supported CAP Operations
@Section Examples
@Section GAP Categories


@Chapter Fitting Parameters

@Section Introduction
@Section Notes on Batching
@Section Operations
@Section Examples

@Chapter CAP Operations for GradientBasedLearningForCAP

@Section Basic Operations
@Section Add-Methods

@Chapter Tools

@Section Mathematical Operations
@Section List Operations
@Section Helper Functions
@Section Python Integration
2 changes: 1 addition & 1 deletion doc/clean
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/bin/sh
rm -f *.{aux,bbl,blg,brf,css,html,idx,ilg,ind,js,lab,log,out,pdf,pnr,six,tex,toc,txt,xml,xml.bib}
Binary file added doc/sigmoid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading