kan_head
Bases: head
A knowledge-aware network (KAN)-based head using B-spline expansion.
Supports B-spline-based data transformation, parameter reconciliation, and flexible output processing.
Attributes:
Name | Type | Description |
---|---|---|
m |
int
|
Input dimension of the head. |
n |
int
|
Output dimension of the head. |
grid_range |
tuple
|
Range for B-spline grid. |
t |
int
|
Number of knots for B-spline. |
d |
int
|
Degree of the B-spline. |
channel_num |
int
|
Number of channels for multi-channel processing. |
parameters_init_method |
str
|
Initialization method for parameters. |
device |
str
|
Device to host the head (e.g., 'cpu' or 'cuda'). |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the KAN head with specified configurations. |
Source code in tinybig/head/basic_heads.py
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 |
|
__init__(m, n, grid_range=(-1, 1), t=5, d=3, name='kan_head', enable_bias=False, with_lorr=False, r=3, channel_num=1, with_batch_norm=False, with_softmax=False, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initializes the KAN head.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
Input dimension. |
required |
n
|
int
|
Output dimension. |
required |
grid_range
|
tuple
|
Range for B-spline grid, default is (-1, 1). |
(-1, 1)
|
t
|
int
|
Number of knots for B-spline, default is 5. |
5
|
d
|
int
|
Degree of the B-spline, default is 3. |
3
|
name
|
str
|
Name of the KAN head, default is 'kan_head'. |
'kan_head'
|
enable_bias
|
bool
|
Whether to enable bias in reconciliation functions, default is False. |
False
|
with_lorr
|
bool
|
Whether to use LORR reconciliation, default is False. |
False
|
r
|
int
|
Parameter for reconciliation functions, default is 3. |
3
|
channel_num
|
int
|
Number of channels, default is 1. |
1
|
with_batch_norm
|
bool
|
Whether to include batch normalization, default is False. |
False
|
with_softmax
|
bool
|
Whether to use softmax activation, default is False. |
False
|
parameters_init_method
|
str
|
Initialization method for parameters, default is 'xavier_normal'. |
'xavier_normal'
|
device
|
str
|
Device to host the head, default is 'cpu'. |
'cpu'
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in tinybig/head/basic_heads.py
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 |
|