API Reference¶
Complete reference for every class and function in Neurogebra.
New here?
Start with the tutorials first, then come back here when you need details.
Quick Import Guide¶
# Core imports — you'll use these the most
from neurogebra import MathForge, Expression
# Autograd (manual neural networks)
from neurogebra.core.autograd import Value, Tensor
# Training
from neurogebra.core.trainer import Trainer
# Model building
from neurogebra.builders.model_builder import ModelBuilder
# Educational interface
from neurogebra.core.neurocraft import NeuroCraft
# Datasets
from neurogebra.datasets import Datasets, ExpandedDatasets
Core Classes¶
Expression¶
The fundamental building block — a mathematical expression with symbolic and numerical capabilities.
neurogebra.core.expression.Expression
¶
Unified mathematical expression supporting symbolic, numerical, and trainable operations.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Human-readable name of the expression |
|
symbolic_expr |
SymPy symbolic representation |
|
params |
Dictionary of parameters |
|
trainable_params |
List of parameter names that can be trained |
|
metadata |
Additional information about the expression |
Source code in neurogebra/core/expression.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
Attributes¶
formula
property
¶
Get LaTeX representation of the expression.
Functions¶
__init__(name, symbolic_expr, params=None, trainable_params=None, metadata=None)
¶
Initialize an Expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name identifier for the expression |
required |
symbolic_expr
|
Union[str, Expr]
|
Symbolic mathematical expression (string or SymPy) |
required |
params
|
Optional[Dict[str, Any]]
|
Dictionary of parameter values |
None
|
trainable_params
|
Optional[List[str]]
|
List of parameters that can be trained |
None
|
metadata
|
Optional[Dict[str, Any]]
|
Additional information (description, usage, etc.) |
None
|
Source code in neurogebra/core/expression.py
eval(*args, **kwargs)
¶
Evaluate the expression numerically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for variables |
()
|
**kwargs
|
Any
|
Keyword arguments for variables |
{}
|
Returns:
| Type | Description |
|---|---|
Union[float, ndarray]
|
Numerical result (float or numpy array) |
Examples:
Source code in neurogebra/core/expression.py
gradient(var)
¶
Compute symbolic gradient with respect to a variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
Union[str, Symbol]
|
Variable to differentiate with respect to |
required |
Returns:
| Type | Description |
|---|---|
Expression
|
New Expression representing the gradient |
Source code in neurogebra/core/expression.py
compose(other)
¶
Compose two expressions: self(other(x)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Expression
|
Expression to compose with |
required |
Returns:
| Type | Description |
|---|---|
Expression
|
New composed Expression |
Source code in neurogebra/core/expression.py
clone()
¶
Create a deep copy of this expression.
Returns:
| Type | Description |
|---|---|
Expression
|
New Expression with copied attributes |
Source code in neurogebra/core/expression.py
visualize(x_range=(-5, 5), n_points=500, interactive=False, **kwargs)
¶
Visualize this expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_range
|
Tuple[float, float]
|
Range for x-axis |
(-5, 5)
|
n_points
|
int
|
Number of points |
500
|
interactive
|
bool
|
Use interactive plotly plot |
False
|
**kwargs
|
Any
|
Additional plot parameters |
{}
|
Source code in neurogebra/core/expression.py
__call__(*args, **kwargs)
¶
__add__(other)
¶
Add two expressions.
Source code in neurogebra/core/expression.py
__radd__(other)
¶
Right addition.
Source code in neurogebra/core/expression.py
__sub__(other)
¶
Subtract two expressions.
Source code in neurogebra/core/expression.py
__mul__(other)
¶
Multiply two expressions.
Source code in neurogebra/core/expression.py
__rmul__(other)
¶
Right multiplication.
Source code in neurogebra/core/expression.py
__truediv__(other)
¶
Divide two expressions.
Source code in neurogebra/core/expression.py
__pow__(other)
¶
Power of expression.
Source code in neurogebra/core/expression.py
__neg__()
¶
simplify()
¶
Return a simplified version of the expression.
Returns:
| Type | Description |
|---|---|
Expression
|
New simplified Expression |
Source code in neurogebra/core/expression.py
expand()
¶
Return an expanded version of the expression.
Returns:
| Type | Description |
|---|---|
Expression
|
New expanded Expression |
Source code in neurogebra/core/expression.py
integrate(var)
¶
Compute symbolic integral with respect to a variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
Union[str, Symbol]
|
Variable to integrate with respect to |
required |
Returns:
| Type | Description |
|---|---|
Expression
|
New Expression representing the integral |
Source code in neurogebra/core/expression.py
explain(level='intermediate')
¶
Provide explanation of the expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str
|
Explanation level ('beginner', 'intermediate', 'advanced') |
'intermediate'
|
Returns:
| Type | Description |
|---|---|
str
|
Explanatory text |
Source code in neurogebra/core/expression.py
MathForge¶
Your gateway to a curated library of pre-built mathematical expressions organized by category.
neurogebra.core.forge.MathForge
¶
Central hub for accessing mathematical expressions.
MathForge provides a unified interface to: - Get pre-built expressions - Create custom expressions - Search for expressions - Compose expressions - Train expressions
Examples:
>>> forge = MathForge()
>>> relu = forge.get("relu")
>>> result = relu.eval(x=-5)
>>> print(result) # 0
Source code in neurogebra/core/forge.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
Functions¶
__init__()
¶
get(name, params=None, trainable=False)
¶
Get an expression by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the expression |
required |
params
|
Optional[Dict[str, Any]]
|
Parameter overrides |
None
|
trainable
|
bool
|
Whether to make parameters trainable |
False
|
Returns:
| Type | Description |
|---|---|
Expression
|
Expression instance |
Raises:
| Type | Description |
|---|---|
KeyError
|
If expression not found |
Examples:
>>> forge = MathForge()
>>> sigmoid = forge.get("sigmoid")
>>> custom = forge.get("leaky_relu", params={"alpha": 0.2})
Source code in neurogebra/core/forge.py
register(name, expression)
¶
Register a custom expression in the repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name for the expression |
required |
expression
|
Expression
|
Expression instance to register |
required |
Source code in neurogebra/core/forge.py
search(query)
¶
Search for expressions by name or description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search string |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of matching expression names |
Source code in neurogebra/core/forge.py
list_all(category=None)
¶
List all available expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
Optional[str]
|
Filter by category (e.g., 'activation', 'loss') |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of expression names |
Source code in neurogebra/core/forge.py
compose(expression_str, **params)
¶
Compose expressions using string notation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression_str
|
str
|
Expression like "mse + 0.1*l2" |
required |
**params
|
Any
|
Parameters for composed expression |
{}
|
Returns:
| Type | Description |
|---|---|
Expression
|
Composed Expression |
Examples:
Source code in neurogebra/core/forge.py
explain(name, level='intermediate')
¶
Get explanation for an expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the expression |
required |
level
|
str
|
Detail level ('beginner', 'intermediate', 'advanced') |
'intermediate'
|
Returns:
| Type | Description |
|---|---|
str
|
Explanation string |
Source code in neurogebra/core/forge.py
compare(names)
¶
Compare multiple expressions side by side.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
List[str]
|
List of expression names to compare |
required |
Returns:
| Type | Description |
|---|---|
str
|
Comparison table as string |
Source code in neurogebra/core/forge.py
Trainer¶
Fits trainable expressions to data using SGD or Adam optimization.
neurogebra.core.trainer.Trainer
¶
Trainer for optimizing expression parameters.
Supports various optimization algorithms for fitting expressions to data.
Examples:
>>> from neurogebra.core.expression import Expression
>>> expr = Expression("linear", "a*x + b",
... params={"a": 0.0, "b": 0.0},
... trainable_params=["a", "b"])
>>> trainer = Trainer(expr, learning_rate=0.01)
>>> X = np.array([1, 2, 3, 4, 5])
>>> y = np.array([3, 5, 7, 9, 11]) # y = 2x + 1
>>> history = trainer.fit(X, y, epochs=100)
Source code in neurogebra/core/trainer.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
Functions¶
__init__(expression, learning_rate=0.01, optimizer='sgd')
¶
Initialize Trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Expression to train |
required |
learning_rate
|
float
|
Learning rate for optimization |
0.01
|
optimizer
|
str
|
Optimization algorithm ('sgd', 'adam') |
'sgd'
|
Source code in neurogebra/core/trainer.py
fit(X, y, epochs=100, batch_size=None, loss_fn='mse', verbose=True, callback=None)
¶
Fit expression to data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Input data (N,) or (N, D) |
required |
y
|
ndarray
|
Target data (N,) |
required |
epochs
|
int
|
Number of training epochs |
100
|
batch_size
|
Optional[int]
|
Mini-batch size (None = full batch) |
None
|
loss_fn
|
str
|
Loss function ('mse', 'mae') |
'mse'
|
verbose
|
bool
|
Print training progress |
True
|
callback
|
Optional[Callable]
|
Optional callback function called each epoch |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, List]
|
Training history with loss and parameter values per epoch |
Source code in neurogebra/core/trainer.py
reset()
¶
Value (Autograd)¶
Scalar value with automatic differentiation — the engine behind backpropagation.
neurogebra.core.autograd.Value
¶
Scalar value with automatic differentiation support.
Inspired by micrograd, this class wraps numerical values and tracks computational graphs for backpropagation.
Examples:
>>> a = Value(2.0)
>>> b = Value(3.0)
>>> c = a * b + a
>>> c.backward()
>>> print(a.grad) # dc/da = b + 1 = 4.0
Source code in neurogebra/core/autograd.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
Functions¶
__init__(data, _children=(), _op='')
¶
Initialize a Value node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
float
|
Numerical value |
required |
_children
|
Tuple
|
Parent nodes in computation graph |
()
|
_op
|
str
|
Operation that created this node |
''
|
Source code in neurogebra/core/autograd.py
__add__(other)
¶
Addition with gradient tracking.
Source code in neurogebra/core/autograd.py
__mul__(other)
¶
Multiplication with gradient tracking.
Source code in neurogebra/core/autograd.py
__pow__(other)
¶
Power operation with gradient tracking.
Source code in neurogebra/core/autograd.py
relu()
¶
sigmoid()
¶
Sigmoid activation with gradient.
Source code in neurogebra/core/autograd.py
tanh()
¶
Tanh activation with gradient.
exp()
¶
log()
¶
Natural logarithm with gradient.
backward()
¶
Compute gradients via backpropagation.
Performs topological sort and calls _backward on each node.
Source code in neurogebra/core/autograd.py
Tensor (Autograd)¶
Multi-dimensional array with gradient tracking for batch operations.
neurogebra.core.autograd.Tensor
¶
Multi-dimensional array with autograd support.
Extends Value concept to tensors for mini-batch training.
Examples:
>>> t = Tensor([1.0, 2.0, 3.0], requires_grad=True)
>>> result = t.sum()
>>> result.backward()
>>> print(t.grad) # [1.0, 1.0, 1.0]
Source code in neurogebra/core/autograd.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
Attributes¶
shape
property
¶
Return the shape of the tensor.
ndim
property
¶
Return the number of dimensions.
Functions¶
__init__(data, requires_grad=False)
¶
Initialize a Tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[List, ndarray, Any]
|
Array-like data (list, numpy array, etc.) |
required |
requires_grad
|
bool
|
Whether to track gradients |
False
|
Source code in neurogebra/core/autograd.py
backward(gradient=None)
¶
Compute gradients via backpropagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gradient
|
Optional[ndarray]
|
Upstream gradient. If None, uses ones. |
None
|
Source code in neurogebra/core/autograd.py
zero_grad()
¶
sum()
¶
Sum all elements.
Source code in neurogebra/core/autograd.py
mean()
¶
Mean of all elements.
Source code in neurogebra/core/autograd.py
__add__(other)
¶
Element-wise addition.
Source code in neurogebra/core/autograd.py
__mul__(other)
¶
Element-wise multiplication.
Source code in neurogebra/core/autograd.py
__sub__(other)
¶
__neg__()
¶
__pow__(power)
¶
Element-wise power.
Source code in neurogebra/core/autograd.py
Builders¶
ModelBuilder¶
Keras-like interface for building neural network architectures layer by layer.
neurogebra.builders.model_builder.ModelBuilder
¶
Build neural networks with an educational, intuitive interface.
ModelBuilder makes it easy for beginners to: - Understand what they're building - Get guidance on architecture choices - See what each layer does - Learn best practices
Examples:
>>> from neurogebra.builders import ModelBuilder
>>> builder = ModelBuilder()
>>> model = builder.Sequential([
... builder.Dense(128, activation="relu"),
... builder.Dropout(0.2),
... builder.Dense(10, activation="softmax")
... ])
>>> model.summary()
Source code in neurogebra/builders/model_builder.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | |
Functions¶
__init__(craft=None)
¶
Initialize ModelBuilder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
craft
|
Optional[Any]
|
NeuroCraft instance for expression access. If None, a default one is created internally. |
None
|
Source code in neurogebra/builders/model_builder.py
Dense(units, activation=None, input_shape=None, **kwargs)
¶
Create a fully connected (dense) layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
units
|
int
|
Number of neurons |
required |
activation
|
Optional[str]
|
Activation function name |
None
|
input_shape
|
Optional[tuple]
|
Shape of input (only for first layer) |
None
|
Returns:
| Type | Description |
|---|---|
Layer
|
Layer instance |
Examples:
>>> builder = ModelBuilder()
>>> layer = builder.Dense(128, activation="relu")
>>> layer.explain() # Learn what it does
Source code in neurogebra/builders/model_builder.py
Conv2D(filters, kernel_size=3, activation=None, **kwargs)
¶
Create a 2D convolutional layer for images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
int
|
Number of filters / feature detectors |
required |
kernel_size
|
int
|
Size of the filter window |
3
|
activation
|
Optional[str]
|
Activation function |
None
|
Returns:
| Type | Description |
|---|---|
Layer
|
Layer instance |
Source code in neurogebra/builders/model_builder.py
Dropout(rate=0.2)
¶
Create a dropout layer for regularization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
float
|
Fraction of neurons to drop (0.0 to 1.0) |
0.2
|
Returns:
| Type | Description |
|---|---|
Layer
|
Layer instance |
Source code in neurogebra/builders/model_builder.py
BatchNorm()
¶
MaxPooling2D(pool_size=2)
¶
Flatten()
¶
Sequential(layers, name=None)
¶
Build a sequential model (layers stacked one after another).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
List[Layer]
|
List of Layer instances |
required |
name
|
Optional[str]
|
Optional name for the model |
None
|
Returns:
| Type | Description |
|---|---|
'Model'
|
Model instance ready for compilation and training |
Examples:
>>> builder = ModelBuilder()
>>> model = builder.Sequential([
... builder.Dense(128, activation="relu"),
... builder.Dropout(0.2),
... builder.Dense(10, activation="softmax")
... ])
>>> model.summary()
Source code in neurogebra/builders/model_builder.py
from_template(template_name, customize=None)
¶
Create a model from a pre-built template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
Name of template (e.g. 'simple_classifier') |
required |
customize
|
Optional[Dict]
|
Optional customizations (not yet implemented) |
None
|
Returns:
| Type | Description |
|---|---|
'Model'
|
Model instance |
Examples:
>>> builder = ModelBuilder()
>>> model = builder.from_template("simple_classifier")
>>> model.explain_architecture()
Source code in neurogebra/builders/model_builder.py
list_templates()
¶
Show all available model templates with descriptions.
Source code in neurogebra/builders/model_builder.py
suggest_architecture(task, input_shape, output_size)
¶
Get architecture suggestions based on your task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str
|
'classification', 'regression', 'image_classification', etc. |
required |
input_shape
|
tuple
|
Shape of your input data |
required |
output_size
|
int
|
Number of outputs |
required |
Examples:
>>> builder = ModelBuilder()
>>> builder.suggest_architecture(
... task="image_classification",
... input_shape=(28, 28, 1),
... output_size=10
... )
Source code in neurogebra/builders/model_builder.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | |
Repository¶
Pre-built expression collections organized by category.
Activations¶
neurogebra.repository.activations.get_activations()
¶
Get dictionary of activation function expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/activations.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
Losses¶
neurogebra.repository.losses.get_losses()
¶
Get dictionary of loss function expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/losses.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
Regularizers¶
neurogebra.repository.regularizers.get_regularizers()
¶
Get dictionary of regularization expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/regularizers.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
Algebra¶
neurogebra.repository.algebra.get_algebra_expressions()
¶
Get dictionary of algebraic expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/algebra.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
Calculus¶
neurogebra.repository.calculus.get_calculus_expressions()
¶
Get dictionary of common calculus expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/calculus.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
Statistics¶
neurogebra.repository.statistics.get_statistics_expressions()
¶
Get dictionary of statistical expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/statistics.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
Linear Algebra¶
neurogebra.repository.linalg.get_linalg_expressions()
¶
Get dictionary of linear algebra expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/linalg.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
Metrics¶
neurogebra.repository.metrics.get_metrics_expressions()
¶
Get dictionary of evaluation metric expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/metrics.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
Transforms¶
neurogebra.repository.transforms.get_transforms_expressions()
¶
Get dictionary of transform expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/transforms.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
Optimization¶
neurogebra.repository.optimization.get_optimization_expressions()
¶
Get dictionary of optimization expressions.
Returns:
| Type | Description |
|---|---|
Dict[str, Expression]
|
Dictionary mapping names to Expression instances |
Source code in neurogebra/repository/optimization.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
Visualization¶
Plotting¶
neurogebra.viz.plotting
¶
Plotting utilities for Neurogebra.
Provides static plotting functions for expressions using matplotlib.
Classes¶
Functions¶
plot_expression(expression, x_range=(-5, 5), n_points=500, title=None, xlabel='x', ylabel='f(x)', figsize=(8, 5), show_grid=True, show_formula=True, ax=None, **eval_kwargs)
¶
Plot a single expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Expression to plot |
required |
x_range
|
Tuple[float, float]
|
(min, max) range for x-axis |
(-5, 5)
|
n_points
|
int
|
Number of points to evaluate |
500
|
title
|
Optional[str]
|
Plot title (defaults to expression name) |
None
|
xlabel
|
str
|
X-axis label |
'x'
|
ylabel
|
str
|
Y-axis label |
'f(x)'
|
figsize
|
Tuple[int, int]
|
Figure size |
(8, 5)
|
show_grid
|
bool
|
Whether to show grid |
True
|
show_formula
|
bool
|
Whether to show formula in legend |
True
|
ax
|
Optional[Axes]
|
Optional matplotlib Axes to plot on |
None
|
**eval_kwargs
|
Any
|
Additional keyword arguments for eval |
{}
|
Returns:
| Type | Description |
|---|---|
Figure
|
matplotlib Figure |
Source code in neurogebra/viz/plotting.py
plot_comparison(expressions, x_range=(-5, 5), n_points=500, title='Expression Comparison', figsize=(10, 6), show_grid=True)
¶
Plot multiple expressions on the same axes for comparison.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expressions
|
List[Expression]
|
List of Expressions to compare |
required |
x_range
|
Tuple[float, float]
|
(min, max) range for x-axis |
(-5, 5)
|
n_points
|
int
|
Number of points |
500
|
title
|
str
|
Plot title |
'Expression Comparison'
|
figsize
|
Tuple[int, int]
|
Figure size |
(10, 6)
|
show_grid
|
bool
|
Whether to show grid |
True
|
Returns:
| Type | Description |
|---|---|
Figure
|
matplotlib Figure |
Source code in neurogebra/viz/plotting.py
plot_gradient(expression, var='x', x_range=(-5, 5), n_points=500, figsize=(10, 5))
¶
Plot expression alongside its gradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Expression to plot |
required |
var
|
str
|
Variable to differentiate with respect to |
'x'
|
x_range
|
Tuple[float, float]
|
(min, max) range for x-axis |
(-5, 5)
|
n_points
|
int
|
Number of points |
500
|
figsize
|
Tuple[int, int]
|
Figure size |
(10, 5)
|
Returns:
| Type | Description |
|---|---|
Figure
|
matplotlib Figure |
Source code in neurogebra/viz/plotting.py
plot_training_history(history, figsize=(12, 4))
¶
Plot training history (loss and accuracy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
Dict[str, List]
|
Training history dict with 'loss', 'val_loss', 'accuracy', 'val_accuracy' keys |
required |
figsize
|
Tuple[int, int]
|
Figure size |
(12, 4)
|
Returns:
| Type | Description |
|---|---|
Figure
|
matplotlib Figure |
Source code in neurogebra/viz/plotting.py
Interactive¶
neurogebra.viz.interactive
¶
Interactive visualization tools for Neurogebra.
Provides interactive plotting using plotly (optional dependency).
Classes¶
Functions¶
check_plotly()
¶
Raise if plotly is not installed.
interactive_plot(expression, x_range=(-5, 5), n_points=500, title=None)
¶
Create an interactive plot of an expression using Plotly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Expression to plot |
required |
x_range
|
Tuple[float, float]
|
(min, max) range for x values |
(-5, 5)
|
n_points
|
int
|
Number of evaluation points |
500
|
title
|
Optional[str]
|
Plot title |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in neurogebra/viz/interactive.py
interactive_comparison(expressions, x_range=(-5, 5), n_points=500, title='Expression Comparison')
¶
Interactive comparison of multiple expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expressions
|
List[Expression]
|
List of Expressions to compare |
required |
x_range
|
Tuple[float, float]
|
(min, max) range |
(-5, 5)
|
n_points
|
int
|
Number of points |
500
|
title
|
str
|
Plot title |
'Expression Comparison'
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly Figure object |
Source code in neurogebra/viz/interactive.py
Utilities¶
Helpers¶
neurogebra.utils.helpers
¶
Helper utilities for Neurogebra.
Provides common utility functions used across the library.
Functions¶
validate_array(data, name='input')
¶
Validate and convert input to numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data (list, tuple, numpy array, or scalar) |
required |
name
|
str
|
Name for error messages |
'input'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
NumPy array |
Raises:
| Type | Description |
|---|---|
TypeError
|
If data cannot be converted |
Source code in neurogebra/utils/helpers.py
clip_gradients(gradients, max_norm=1.0)
¶
Clip gradients by global norm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gradients
|
Dict[str, float]
|
Dictionary of parameter name -> gradient value |
required |
max_norm
|
float
|
Maximum allowed gradient norm |
1.0
|
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Clipped gradients |
Source code in neurogebra/utils/helpers.py
numerical_gradient(func, x, epsilon=1e-05)
¶
Compute numerical gradient using central differences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
Function to differentiate |
required |
x
|
ndarray
|
Point at which to compute gradient |
required |
epsilon
|
float
|
Step size for finite differences |
1e-05
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Gradient array |
Source code in neurogebra/utils/helpers.py
normalize(data, method='minmax')
¶
Normalize data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Input array |
required |
method
|
str
|
Normalization method ('minmax', 'standard', 'l2') |
'minmax'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Normalized array |
Source code in neurogebra/utils/helpers.py
generate_data(func, x_range=(-5, 5), n_points=100, noise_std=0.0, seed=None)
¶
Generate synthetic data from a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
Function to generate data from |
required |
x_range
|
tuple
|
(min, max) range for x values |
(-5, 5)
|
n_points
|
int
|
Number of data points |
100
|
noise_std
|
float
|
Standard deviation of Gaussian noise |
0.0
|
seed
|
Optional[int]
|
Random seed for reproducibility |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple of (X, y) arrays |
Source code in neurogebra/utils/helpers.py
Explain¶
neurogebra.utils.explain.ExpressionExplainer
¶
Generates detailed explanations of mathematical expressions.
Supports multiple difficulty levels and output formats.
Source code in neurogebra/utils/explain.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
Functions¶
explain(expression, level='intermediate', format='text')
staticmethod
¶
Generate explanation for an expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Expression to explain |
required |
level
|
str
|
Detail level ('beginner', 'intermediate', 'advanced') |
'intermediate'
|
format
|
str
|
Output format ('text', 'markdown', 'latex') |
'text'
|
Returns:
| Type | Description |
|---|---|
str
|
Explanation string |
Source code in neurogebra/utils/explain.py
compare_expressions(expressions, format='text')
staticmethod
¶
Compare multiple expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expressions
|
list
|
List of Expression instances |
required |
format
|
str
|
Output format |
'text'
|
Returns:
| Type | Description |
|---|---|
str
|
Comparison string |
Source code in neurogebra/utils/explain.py
Framework Bridges¶
Convert Neurogebra expressions to production frameworks.
PyTorch Bridge¶
neurogebra.bridges.pytorch_bridge
¶
PyTorch bridge for Neurogebra expressions.
Converts Neurogebra expressions to PyTorch-compatible modules.
Classes¶
Functions¶
check_torch()
¶
Raise if PyTorch is not installed.
to_pytorch(expression)
¶
Convert a Neurogebra Expression to a PyTorch nn.Module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Neurogebra Expression instance |
required |
Returns:
| Type | Description |
|---|---|
Module
|
PyTorch nn.Module that implements the expression and gradient flow. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If PyTorch is not installed |
ValueError
|
If expression has more than one runtime input variable |
Notes
This bridge supports single-input expressions (for example, x -> f(x)). Trainable scalar parameters are supported and receive gradients using symbolic differentiation.
Source code in neurogebra/bridges/pytorch_bridge.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
from_pytorch(module, name='pytorch_expr')
¶
Create a Neurogebra Expression from a simple PyTorch activation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
PyTorch module (e.g., nn.ReLU()) |
required |
name
|
str
|
Name for the expression |
'pytorch_expr'
|
Returns:
| Type | Description |
|---|---|
Expression
|
Neurogebra Expression |
Note
This creates a numerical-only expression (no symbolic form).
Source code in neurogebra/bridges/pytorch_bridge.py
TensorFlow Bridge¶
neurogebra.bridges.tensorflow_bridge
¶
TensorFlow bridge for Neurogebra expressions.
Converts Neurogebra expressions to TensorFlow-compatible functions.
Classes¶
Functions¶
check_tensorflow()
¶
Raise if TensorFlow is not installed.
Source code in neurogebra/bridges/tensorflow_bridge.py
to_tensorflow(expression)
¶
Convert a Neurogebra Expression to a TensorFlow function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Neurogebra Expression instance |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
TensorFlow-compatible function |
Raises:
| Type | Description |
|---|---|
ImportError
|
If TensorFlow is not installed |
ValueError
|
If expression has more than one runtime input variable |
Source code in neurogebra/bridges/tensorflow_bridge.py
to_keras_layer(expression, name=None)
¶
Convert a Neurogebra Expression to a Keras Layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Neurogebra Expression instance |
required |
name
|
Optional[str]
|
Optional layer name |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Keras Lambda layer |
Raises:
| Type | Description |
|---|---|
ValueError
|
If expression has more than one runtime input variable |
Source code in neurogebra/bridges/tensorflow_bridge.py
JAX Bridge¶
neurogebra.bridges.jax_bridge
¶
JAX bridge for Neurogebra expressions.
Converts Neurogebra expressions to JAX-compatible functions.
Classes¶
Functions¶
check_jax()
¶
to_jax(expression)
¶
Convert a Neurogebra Expression to a JAX-compatible function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Neurogebra Expression instance |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
JAX-compatible function for eager evaluation. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If JAX is not installed |
ValueError
|
If expression has more than one runtime input variable |
Notes
This bridge uses NumPy-backed evaluation under the hood. It is intended for interoperability, not traced JIT/grad execution.
Source code in neurogebra/bridges/jax_bridge.py
to_jax_grad(expression, var='x')
¶
Convert expression and return its gradient as a JAX function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
Expression
|
Neurogebra Expression instance |
required |
var
|
str
|
Variable to differentiate with respect to |
'x'
|
Returns:
| Type | Description |
|---|---|
Callable
|
JAX function computing the gradient |