model_with_bridge
ModelWithBridge
¶
Bases: torch.nn.Module
Implementation of the bridge architecture described in Gradually Vanishing Bridge for Adversarial Domain Adaptation.
Source code in pytorch_adapt\layers\model_with_bridge.py
9 10 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 |
|
__init__(model, bridge=None)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
torch.nn.Module
|
Any pytorch model. |
required |
bridge |
torch.nn.Module
|
A model which has the same input/output sizes as |
None
|
Source code in pytorch_adapt\layers\model_with_bridge.py
15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
forward(x, return_bridge=False)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
torch.Tensor
|
The input to both |
required |
return_bridge |
bool
|
Whether or not to return the bridge output
in addition to the |
False
|
Returns:
Type | Description |
---|---|
Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]
|
If |
Source code in pytorch_adapt\layers\model_with_bridge.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|