naive_bayes_head
Bases: head
A Naive Bayes-based head for implementing multi-channel modules.
This head supports various probability distributions, including normal, exponential, cauchy, gamma, chi-squared, and Laplace. It also allows for optional parameter reconciliation and residual connections.
Attributes:
Name | Type | Description |
---|---|---|
m |
int
|
Input dimension of the head. |
n |
int
|
Output dimension of the head. |
distribution |
str
|
Type of probability distribution ('normal', 'exponential', 'cauchy', 'gamma', 'chi2', 'laplace'). |
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 Naive Bayes head with specified configurations. |
Source code in tinybig/head/basic_heads.py
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 |
|
__init__(m, n, name='perceptron_head', distribution='normal', enable_bias=False, with_lorr=False, r=3, with_residual=False, channel_num=1, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initializes the Naive Bayes head.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
Input dimension. |
required |
n
|
int
|
Output dimension. |
required |
name
|
str
|
Name of the Naive Bayes head, default is 'naive_bayes_head'. |
'perceptron_head'
|
distribution
|
str
|
Probability distribution ('normal', 'exponential', 'cauchy', 'gamma', 'chi2', 'laplace'), default is 'normal'. |
'normal'
|
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
|
with_residual
|
bool
|
Whether to include a residual connection, default is False. |
False
|
channel_num
|
int
|
Number of channels for multi-channel processing, default is 1. |
1
|
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
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 |
|