Scattering transform API documentation¶
ScatteringTransform ¶
ScatteringTransform(W_adj, n_scales, n_layers, nlin=torch.abs, **kwargs)
Bases: nn.Module
ScatteringTransform base class. Inherits from PyTorch nn.Module
This class implements the base logic to compute graph scattering transforms with a pooling and an arbitrary wavelet transform operators.
This is a base class, and implements only the logic to compute
an arbitrary scattering transform. The method get_wavelets
must be implemented by the subclass
Parameters:
Name | Type | Description | Default |
---|---|---|---|
W_adj |
torch.Tensor
|
Weighted adjacency matrix |
required |
n_scales |
int
|
Number of scales to use in wavelet transform |
required |
n_layers |
int
|
Number of layers in the scattering transform |
required |
nlin |
Callable[[torch.Tensor], torch.Tensor]
|
Non-linearity used in the scattering transform. Defaults to torch.abs |
torch.abs
|
**kwargs |
Any
|
Additional keyword arguments |
{}
|
Source code in gsxform/scattering.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
forward ¶
forward(x)
Forward pass of a generic scattering transform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
torch.Tensor
|
input batch of graph signals |
required |
Returns:
Name | Type | Description |
---|---|---|
phi |
torch.Tensor
|
scattering representation of the input batch |
Source code in gsxform/scattering.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
get_lowpass ¶
get_lowpass()
Compute lowpass filtering/pooling operator.
This should roughly resemble an average, it alters the output scaling factor. For instance averaging with the norm of the degree vector scales towards zero, this implementation offers a more natural scaling.
Returns:
Name | Type | Description |
---|---|---|
lowpass |
torch.Tensor
|
average pooling operator |
Source code in gsxform/scattering.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
get_wavelets ¶
get_wavelets()
Compute wavelet operator. Subclasses are required to implement this method
Source code in gsxform/scattering.py
71 72 73 74 75 |
|
Diffusion ¶
Diffusion(W_adj, n_scales, n_layers, nlin=torch.abs)
Bases: ScatteringTransform
Diffusion scattering transform.
Subclass of ScatteringTransform
, implements get_wavelets
method.
Diffusion scattering transform algorithm based on description
in Gama et. al 2018.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
W_adj |
torch.Tensor
|
Weighted adjacency matrix |
required |
n_scales |
int
|
Number of scales to use in wavelet transform |
required |
n_layers |
int
|
Number of layers in the scattering transform |
required |
nlin |
Callable[[torch.Tensor], torch.Tensor]
|
Non-linearity used in the scattering transform. Defaults to torch.abs |
torch.abs
|
Source code in gsxform/scattering.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
get_wavelets ¶
get_wavelets()
Subclass method used to get wavelet filter bank
This method returns diffusion wavelets
Returns:
Name | Type | Description |
---|---|---|
psi |
torch.Tensor
|
diffusion wavelet operator |
Source code in gsxform/scattering.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
TightHann ¶
TightHann(W_adj, n_scales, n_layers, nlin=torch.abs, use_warp=True)
Bases: ScatteringTransform
TightHann scattering transform.
Subclass of ScatteringTransform
, implements get_wavelets
methods.
Also additionally implements functions used to compute spectrum-adaptive
wavelets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
W_adj |
torch.Tensor
|
Weighted adjacency matrix |
required |
n_scales |
int
|
Number of scales to use in wavelet transform |
required |
n_layers |
int
|
Number of layers in the scattering transform |
required |
nlin |
Callable[[torch.Tensor], torch.Tensor]
|
Non-linearity used in the scattering transform. Defaults to torch.abs |
torch.abs
|
use_warp |
bool
|
Use warping function. Defaults to True |
True
|
Source code in gsxform/scattering.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
get_kernel ¶
get_kernel()
compute TightHann kernel adaptively
Source code in gsxform/scattering.py
264 265 266 267 268 269 |
|
get_wavelets ¶
get_wavelets()
Subclass method used to get wavelet filter bank
This method returns diffusion wavelets
Returns:
Name | Type | Description |
---|---|---|
psi |
torch.Tensor
|
diffusion wavelet operator |
Source code in gsxform/scattering.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
warp_func ¶
warp_func()
Implements spectrum-adaptive warping function
Source code in gsxform/scattering.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|