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
4 changes: 2 additions & 2 deletions PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "GradientDescentForCAP",
Subtitle := "Exploring categorical machine learning in CAP",
Version := "2024.09-01",
Version := "2025.11-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 Down Expand Up @@ -67,7 +67,7 @@ PackageDoc := rec(
),

Dependencies := rec(
GAP := ">= 4.13.0",
GAP := ">= 4.15.1",
NeededOtherPackages := [
[ "GAPDoc", ">= 1.5" ],
[ "CAP", ">= 2024.09-12" ],
Expand Down
4 changes: 2 additions & 2 deletions examples/CategoryOfLenses.g
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ Display( Lenses.AdagradOptimizer( :learning_rate := 0.01 )( 2 ) );
#!
#! ‣ x1 + x5 ^ 2
#! ‣ x2 + x6 ^ 2
#! ‣ x3 + 0.01 * x5 / (1.e-07 + Sqrt( (x1 + x5 ^ 2) ))
#! ‣ x4 + 0.01 * x6 / (1.e-07 + Sqrt( (x2 + x6 ^ 2) ))
#! ‣ x3 + 0.01 * x5 / (1.e-07 + Sqrt( x1 + x5 ^ 2 ))
#! ‣ x4 + 0.01 * x6 / (1.e-07 + Sqrt( x2 + x6 ^ 2 ))
Display( Lenses.AdamOptimizer(
:learning_rate := 0.01, beta_1 := 0.9, beta_2 := 0.999 )( 2 ) );
#! (ℝ^7, ℝ^7) -> (ℝ^2, ℝ^2) defined by:
Expand Down
12 changes: 6 additions & 6 deletions examples/CategoryOfSkeletalSmoothMaps.g
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Display( h );
#!
#! ‣ 3 * (x1 ^ 2 + Sin( x2 ))
#! ‣ Exp( Exp( x1 ) + 3 * x2 )
#! ‣ (x1 ^ 2 + Sin( x2 )) ^ 3 + Log( (Exp( x1 ) + 3 * x2) )
#! ‣ (x1 ^ 2 + Sin( x2 )) ^ 3 + Log( Exp( x1 ) + 3 * x2 )
x;
#! [ 0.2, 0.3 ]
Map( h )( x );
Expand All @@ -94,7 +94,7 @@ Display( s );
#!
#! ‣ 3 * x1 ^ 2 + 3 * Sin( x2 )
#! ‣ Exp( 3 * x2 + Exp( x1 ) )
#! ‣ (x1 ^ 2 + Sin( x2 )) ^ 3 + Log( (3 * x2 + Exp( x1 )) )
#! ‣ (x1 ^ 2 + Sin( x2 )) ^ 3 + Log( 3 * x2 + Exp( x1 ) )
R2 := Smooth.( 2 );
#! ℝ^2
R3 := Smooth.( 3 );
Expand Down Expand Up @@ -221,8 +221,8 @@ Display( Smooth.PowerBase( 6 ) );
Display( Smooth.Sigmoid( 2 ) );
#! ℝ^2 -> ℝ^2
#!
#! ‣ 1 / (1 + Exp( (- x1) ))
#! ‣ 1 / (1 + Exp( (- x2) ))
#! ‣ 1 / (1 + Exp( - x1 ))
#! ‣ 1 / (1 + Exp( - x2 ))
Display( Smooth.Softmax( 2 ) );
#! ℝ^2 -> ℝ^2
#!
Expand All @@ -235,11 +235,11 @@ Display( Smooth.QuadraticLoss( 2 ) );
Display( Smooth.BinaryCrossEntropyLoss( 1 ) );
#! ℝ^2 -> ℝ^1
#!
#! ‣ - (x2 * Log( x1 ) + (1 - x2) * Log( (1 - x1) ))
#! ‣ - (x2 * Log( x1 ) + (1 - x2) * Log( 1 - x1 ))
Display( Smooth.SigmoidBinaryCrossEntropyLoss( 1 ) );
#! ℝ^2 -> ℝ^1
#!
#! ‣ Log( 1 + Exp( (- x1) ) ) + (1 - x2) * x1
#! ‣ Log( 1 + Exp( - x1 ) ) + (1 - x2) * x1
Display( Smooth.CrossEntropyLoss( 3 ) );
#! ℝ^6 -> ℝ^1
#!
Expand Down
6 changes: 3 additions & 3 deletions examples/Expressions.g
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ e1 + e2;
e1 * e2;
#! (x + Sin( y ) * Log( z )) * (x * y + Sin( z )) ^ 2
e := Sin( e1 ) / e2;
#! Sin( (x + Sin( y ) * Log( z )) ) / (x * y + Sin( z )) ^ 2
#! Sin( x + Sin( y ) * Log( z ) ) / (x * y + Sin( z )) ^ 2
f := AsFunction( e );
#! function( vec ) ... end
Display( f );
Expand All @@ -36,7 +36,7 @@ Display( f );
#! x := vec[1];
#! y := vec[2];
#! z := vec[3];
#! return Sin( (x + Sin( y ) * Log( z )) ) / (x * y + Sin( z )) ^ 2;
#! return Sin( x + Sin( y ) * Log( z ) ) / (x * y + Sin( z )) ^ 2;
#! end
x := [ 3, 2, 4 ];
#! [ 3, 2, 4 ]
Expand All @@ -45,7 +45,7 @@ f( x );
dummy_input := ConvertToExpressions( [ "x1", "x2", "x3" ] );
#! [ x1, x2, x3 ]
f( dummy_input );
#! Sin( (x1 + Sin( x2 ) * Log( x3 )) ) / (x1 * x2 + Sin( x3 )) ^ 2
#! Sin( x1 + Sin( x2 ) * Log( x3 ) ) / (x1 * x2 + Sin( x3 )) ^ 2
AssignExpressions( dummy_input );
#! #I MakeReadWriteGlobal: x1 already read-write
#! #I MakeReadWriteGlobal: x2 already read-write
Expand Down
2 changes: 0 additions & 2 deletions gap/CategoryOfSkeletalSmoothMaps.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ DeclareCategory( "IsMorphismInCategoryOfSkeletalSmoothMaps",

DeclareGlobalFunction( "CategoryOfSkeletalSmoothMaps" );

DeclareGlobalVariable( "SkeletalSmoothMaps" );

DeclareOperation( "SmoothMorphism",
[ IsCategoryOfSkeletalSmoothMaps, IsObjectInCategoryOfSkeletalSmoothMaps, IsDenseList, IsObjectInCategoryOfSkeletalSmoothMaps ] );

Expand Down
2 changes: 1 addition & 1 deletion gap/CategoryOfSkeletalSmoothMaps.gi
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ InstallGlobalFunction( CategoryOfSkeletalSmoothMaps,
end );

##
InstallValue( SkeletalSmoothMaps, CategoryOfSkeletalSmoothMaps( ) );
BindGlobal( "SkeletalSmoothMaps", CategoryOfSkeletalSmoothMaps( ) );

##
InstallOtherMethod( IsCongruentForMorphisms,
Expand Down
1 change: 0 additions & 1 deletion tst/example-in-readme-1.tst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
gap> LoadPackage( "GradientDescentForCAP" );
true

gap> Para := CategoryOfParametrisedMorphisms( SkeletalSmoothMaps );
CategoryOfParametrisedMorphisms( SkeletalSmoothMaps )

Expand Down
39 changes: 21 additions & 18 deletions tst/example-in-readme-2.tst
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ Underlying Morphism:
-------------------
ℝ^11 -> ℝ^3

‣ Exp( (theta_1 * x1 + theta_2 * x2 + theta_3) )
/ (Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) ) + Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) ))
‣ Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) )
/ (Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) ) + Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) ))
‣ Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) )
/ (Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) ) + Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) ))
‣ Exp( theta_1 * x1 + theta_2 * x2 + theta_3 )
/ (Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( theta_4 * x1 + theta_5 * x2 + theta_6 ) + Exp( theta_7 * x1 + theta_8 * x2 + theta_9 ))
‣ Exp( theta_4 * x1 + theta_5 * x2 + theta_6 )
/ (Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( theta_4 * x1 + theta_5 * x2 + theta_6 ) + Exp( theta_7 * x1 + theta_8 * x2 + theta_9 ))
‣ Exp( theta_7 * x1 + theta_8 * x2 + theta_9 )
/ (Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( theta_4 * x1 + theta_5 * x2 + theta_6 ) + Exp( theta_7 * x1 + theta_8 * x2 + theta_9 ))

gap> parameters := [ 0.1, -0.1, 0, 0.1, 0.2, 0, -0.2, 0.3, 0 ];;

gap> x := [ 1, 2 ];;

gap> prediction_x := Eval( f, [ parameters, x ] );
Expand All @@ -64,9 +65,11 @@ Underlying Morphism:
-------------------
ℝ^14 -> ℝ^1

‣ ((Log( Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) ) + Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) ) ) - (theta_1 * x1 + theta_2 * x2 + theta_3)) * y1
+ (Log( Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) ) + Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) ) ) - (theta_4 * x1 + theta_5 * x2 + theta_6)) * y2
+ (Log( Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( (theta_4 * x1 + theta_5 * x2 + theta_6) ) + Exp( (theta_7 * x1 + theta_8 * x2 + theta_9) ) ) - (theta_7 * x1 + theta_8 * x2 + theta_9)) * y3) / 3
‣ ((Log( Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( theta_4 * x1 + theta_5 * x2 + theta_6 ) + Exp( theta_7 * x1 + theta_8 * x2 + theta_9 ) )
- (theta_1 * x1 + theta_2 * x2 + theta_3)) * y1 + (Log( Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( theta_4 * x1 + theta_5 * x2 + theta_6 )
+ Exp( theta_7 * x1 + theta_8 * x2 + theta_9 ) ) - (theta_4 * x1 + theta_5 * x2 + theta_6)) * y2
+ (Log( Exp( theta_1 * x1 + theta_2 * x2 + theta_3 ) + Exp( theta_4 * x1 + theta_5 * x2 + theta_6 ) + Exp( theta_7 * x1 + theta_8 * x2 + theta_9 ) )
- (theta_7 * x1 + theta_8 * x2 + theta_9)) * y3) / 3

gap> Lenses := CategoryOfLenses( SkeletalSmoothMaps );
CategoryOfLenses( SkeletalSmoothMaps )
Expand Down Expand Up @@ -130,18 +133,18 @@ Underlying Morphism:
-------------------
ℝ^2 -> ℝ^3

‣ Exp( (5.09137 * x1 + (- 4.83379) * x2 + 3.06257) )
‣ Exp( 5.09137 * x1 + (- 4.83379) * x2 + 3.06257 )
/ (Exp( 5.09137 * x1 + (- 4.83379) * x2 + 3.06257 )
+ Exp( ((- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622)) )
+ Exp( ((- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856)) ))
‣ Exp( ((- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622)) )
+ Exp( (- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622) )
+ Exp( (- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856) ))
‣ Exp( (- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622) )
/ (Exp( 5.09137 * x1 + (- 4.83379) * x2 + 3.06257 )
+ Exp( ((- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622)) )
+ Exp( ((- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856)) ))
‣ Exp( ((- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856)) )
+ Exp( (- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622) )
+ Exp( (- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856) ))
‣ Exp( (- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856) )
/ (Exp( 5.09137 * x1 + (- 4.83379) * x2 + 3.06257 )
+ Exp( ((- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622)) )
+ Exp( ((- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856)) ))
+ Exp( (- 5.70976) * x1 + 0.837175 * x2 + (- 4.23622) )
+ Exp( (- 1.71171) * x1 + 5.54301 * x2 + (- 4.80856) ))

gap> f_theta := UnderlyingMorphism( f_theta );
ℝ^2 -> ℝ^3
Expand Down