diff --git a/PackageInfo.g b/PackageInfo.g index 7105813..1ce60b9 100644 --- a/PackageInfo.g +++ b/PackageInfo.g @@ -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", @@ -67,7 +67,7 @@ PackageDoc := rec( ), Dependencies := rec( - GAP := ">= 4.13.0", + GAP := ">= 4.15.1", NeededOtherPackages := [ [ "GAPDoc", ">= 1.5" ], [ "CAP", ">= 2024.09-12" ], diff --git a/examples/CategoryOfLenses.g b/examples/CategoryOfLenses.g index 6ba7e06..62d48f3 100644 --- a/examples/CategoryOfLenses.g +++ b/examples/CategoryOfLenses.g @@ -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: diff --git a/examples/CategoryOfSkeletalSmoothMaps.g b/examples/CategoryOfSkeletalSmoothMaps.g index 59a78db..a1ea661 100644 --- a/examples/CategoryOfSkeletalSmoothMaps.g +++ b/examples/CategoryOfSkeletalSmoothMaps.g @@ -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 ); @@ -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 ); @@ -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 #! @@ -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 #! diff --git a/examples/Expressions.g b/examples/Expressions.g index c63c147..33347a3 100644 --- a/examples/Expressions.g +++ b/examples/Expressions.g @@ -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 ); @@ -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 ] @@ -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 diff --git a/gap/CategoryOfSkeletalSmoothMaps.gd b/gap/CategoryOfSkeletalSmoothMaps.gd index 9ca9fc8..56e25ab 100644 --- a/gap/CategoryOfSkeletalSmoothMaps.gd +++ b/gap/CategoryOfSkeletalSmoothMaps.gd @@ -17,8 +17,6 @@ DeclareCategory( "IsMorphismInCategoryOfSkeletalSmoothMaps", DeclareGlobalFunction( "CategoryOfSkeletalSmoothMaps" ); -DeclareGlobalVariable( "SkeletalSmoothMaps" ); - DeclareOperation( "SmoothMorphism", [ IsCategoryOfSkeletalSmoothMaps, IsObjectInCategoryOfSkeletalSmoothMaps, IsDenseList, IsObjectInCategoryOfSkeletalSmoothMaps ] ); diff --git a/gap/CategoryOfSkeletalSmoothMaps.gi b/gap/CategoryOfSkeletalSmoothMaps.gi index 4ab2956..5c99e40 100644 --- a/gap/CategoryOfSkeletalSmoothMaps.gi +++ b/gap/CategoryOfSkeletalSmoothMaps.gi @@ -706,7 +706,7 @@ InstallGlobalFunction( CategoryOfSkeletalSmoothMaps, end ); ## -InstallValue( SkeletalSmoothMaps, CategoryOfSkeletalSmoothMaps( ) ); +BindGlobal( "SkeletalSmoothMaps", CategoryOfSkeletalSmoothMaps( ) ); ## InstallOtherMethod( IsCongruentForMorphisms, diff --git a/tst/example-in-readme-1.tst b/tst/example-in-readme-1.tst index 6c77c12..d083f99 100644 --- a/tst/example-in-readme-1.tst +++ b/tst/example-in-readme-1.tst @@ -1,6 +1,5 @@ gap> LoadPackage( "GradientDescentForCAP" ); true - gap> Para := CategoryOfParametrisedMorphisms( SkeletalSmoothMaps ); CategoryOfParametrisedMorphisms( SkeletalSmoothMaps ) diff --git a/tst/example-in-readme-2.tst b/tst/example-in-readme-2.tst index ff4bae5..bb4a40c 100644 --- a/tst/example-in-readme-2.tst +++ b/tst/example-in-readme-2.tst @@ -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 ] ); @@ -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 ) @@ -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