Skip to content

Commit

Permalink
Add Q&A section
Browse files Browse the repository at this point in the history
  • Loading branch information
bdvllrs committed Mar 8, 2024
1 parent 762a17e commit 72202cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ See [Installation instructions](docs/installation.md).
You can find code examples in the `examples` folder. Each subfolder is a different
example.

## Tutorial
You can also follow a tutorial on the basics of shimmer [here](docs/shimmer_basics.md).

You can also find some additional information in the [Q&A](docs/q_and_a.md).

## API Documentation
The full API documentation is available here:
[https://bdvllrs.github.io/shimmer/](https://bdvllrs.github.io/shimmer/).
Expand Down
43 changes: 43 additions & 0 deletions docs/q_and_a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Q&A

## How can I customize my GlobalWorkspace
[`GlobalWorkspaceBase`](https://bdvllrs.github.io/shimmer/shimmer/modules/global_workspace.html#GlobalWorkspaceBase)
is a very generic implementation of the global workspace and uses different building
blocks (given as arguments) to function:
* **gw_mod**: a class implementation of `GWModuleBase` which defines how to encode,
decode, and fuse domains.
* **loss_mod**: a class implementation of `GWLossesBase` which defines computes and
defines losses to train on, and metrics to log.
* aditionnal optimization parameters (see API docs).

Different implementations have been made to initialize the Global Workspace more easily,
but you may need to implement a new one if you have very specific needs.

To get insipiration, you can look at the source code of
[`GlobalWorkspace`](https://bdvllrs.github.io/shimmer/shimmer/modules/global_workspace.html#GlobalWorkspace).

## How can I change the loss function?
If you are using pre-made GW architecture
([`GlobalWorkspace`](https://bdvllrs.github.io/shimmer/shimmer/modules/global_workspace.html#GlobalWorkspace),
[`GlobalWorkspaceWithUncertainty`](https://bdvllrs.github.io/shimmer/shimmer/modules/global_workspace.html#GlobalWorkspaceWithUncertainty),
[`GlobalWorkspaceFusion`](https://bdvllrs.github.io/shimmer/shimmer/modules/global_workspace.html#GlobalWorkspaceFusion) and want to update the loss
used for demi-cycles, cycles, translations or broadcast, you can do so directly from
your definition of the
[`DomainModule`](https://bdvllrs.github.io/shimmer/shimmer/modules/domain.html#DomainModule.compute_loss)
when defining the `compute_loss` method.

You also can have different losses for demi-cycles, cycles, ... by implementing
the corresponding methods
([`compute_dcy_loss`)(https://bdvllrs.github.io/shimmer/shimmer/modules/domain.html#DomainModule.compute_dcy_loss),
[`compute_tr_loss`](https://bdvllrs.github.io/shimmer/shimmer/modules/domain.html#DomainModule.compute_tr_loss), ...).

You can use your own contrastive loss function by passing it as an argument to the
`GlobalWorkspace` class with the `contrastive_loss` loss argument.

If you have more specific needs, like change how the different loss interact, or
completely replace the loss combination we provide, you will need to implement a new
Loss Module inheriting from
[`GWLossesBase`](https://bdvllrs.github.io/shimmer/shimmer/modules/losses.html#GWLossesBase).
Then, you can create a new implementation of
[`GlobalWorkspaceBase`](https://bdvllrs.github.io/shimmer/shimmer/modules/global_workspace.html#GlobalWorkspaceBase)
(see section "How can I customize my GlobalWorkspace" for more details.)

0 comments on commit 72202cb

Please sign in to comment.