grid_compression_head
Bases: head
A head for compressing grid data using geometric compression.
Supports different patch structures (cuboid, cylinder, sphere) and packing strategies for grid data.
Attributes:
Name | Type | Description |
---|---|---|
h |
int
|
Height of the grid. |
w |
int
|
Width of the grid. |
channel_num |
int
|
Number of channels in the grid. |
d |
int, default=1
|
Depth of the grid. |
name |
str
|
Name of the head. |
pooling_metric |
str, default='batch_max'
|
Metric used for pooling operations. |
patch_shape |
str, default='cuboid'
|
Shape of the patch. Options: 'cuboid', 'cylinder', 'sphere'. |
cd_h, cd_w, cd_d |
(int, optional)
|
Parameters for packing and compression. |
packing_strategy |
str, default='densest_packing'
|
Strategy for packing grid patches. |
with_dropout |
bool, default=True
|
Whether to apply dropout during output processing. |
p |
float, default=0.5
|
Dropout probability. |
parameters_init_method |
str, default='xavier_normal'
|
Initialization method for parameters. |
device |
str, default='cpu'
|
Device to run the computations ('cpu' or 'cuda'). |
Methods:
Name | Description |
---|---|
get_patch_size |
Returns the size of the patch. |
get_input_grid_shape |
Returns the shape of the input grid. |
get_output_grid_shape |
Returns the shape of the output grid after packing. |
Source code in tinybig/head/grid_based_heads.py
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 |
|
__init__(h, w, channel_num, d=1, name='grid_compression_head', pooling_metric='batch_max', patch_shape='cuboid', p_h=None, p_h_prime=None, p_w=None, p_w_prime=None, p_d=0, p_d_prime=None, p_r=None, cd_h=None, cd_w=None, cd_d=1, packing_strategy='densest_packing', with_dropout=True, p=0.5, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initializes the grid_compression_head
class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
h
|
int
|
Height of the grid. |
required |
w
|
int
|
Width of the grid. |
required |
channel_num
|
int
|
Number of channels in the grid. |
required |
d
|
int
|
Depth of the grid. |
1
|
name
|
str
|
Name of the head. |
'grid_compression_head'
|
pooling_metric
|
str
|
Metric to use for pooling operations. |
'batch_max'
|
patch_shape
|
str
|
Shape of the patch. Options: 'cuboid', 'cylinder', 'sphere'. |
'cuboid'
|
p_h
|
int
|
Patch height. |
None
|
p_h_prime
|
int
|
Adjusted patch height for the cuboid. |
None
|
p_w
|
int
|
Patch width. Defaults to |
None
|
p_w_prime
|
int
|
Adjusted patch width for the cuboid. |
None
|
p_d
|
int
|
Patch depth. |
0
|
p_d_prime
|
int
|
Adjusted patch depth for the cuboid. |
None
|
p_r
|
int
|
Patch radius (for spherical or cylindrical patches). |
None
|
cd_h
|
int
|
Compression depth in the height dimension. |
None
|
cd_w
|
int
|
Compression depth in the width dimension. |
None
|
cd_d
|
int
|
Compression depth in the depth dimension. |
1
|
packing_strategy
|
str
|
Strategy for packing patches into the grid. |
'densest_packing'
|
with_dropout
|
bool
|
Whether to apply dropout during output processing. |
True
|
p
|
float
|
Dropout probability. |
0.5
|
parameters_init_method
|
str
|
Initialization method for model parameters. |
'xavier_normal'
|
device
|
str
|
Device to run the computations ('cpu' or 'cuda'). |
'cpu'
|
Source code in tinybig/head/grid_based_heads.py
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 |
|
get_input_grid_shape()
Returns the shape of the input grid.
Returns:
Type | Description |
---|---|
tuple
|
A tuple representing (height, width, depth) of the input grid. |
get_output_grid_shape()
Returns the shape of the output grid after packing.
Returns:
Type | Description |
---|---|
tuple
|
A tuple representing (height, width, depth) of the packed grid. |
Source code in tinybig/head/grid_based_heads.py
get_patch_size()
Returns the size of the patch in the grid.
Returns:
Type | Description |
---|---|
int
|
Patch size. |