pyshqg.backend.tensorflow_backend module
Submodule dedicated to tensorflow backend.
- class pyshqg.backend.tensorflow_backend.TensorflowBackend(floatx)
Bases:
BackendTensorflow backend.
- from_numpy(array)
Converts an array from numpy into backend format.
- Parameters:
array (numpy.ndarray) – Array in numpy format.
- Returns:
tensor – Array in backend format.
- Return type:
tensorflow.Tensor
- static to_numpy(tensor)
Converts an array from backend into numpy format.
- Parameters:
tensor (tensorflow.Tensor) – Array in backend format.
- Returns:
array – Array in numpy format.
- Return type:
numpy.ndarray
- static expand_dims(*args, **kwargs)
Wrapper around tensorflow.expand_dims.
- static pad(*args, mode='constant', **kwargs)
Wrapper around tensorflow.pad.
Notes
The kwarg mode is uppercased before being sent to tensorflow.pad in order to match numpy syntax.
- static einsum(*args, **kwargs)
Wrapper around tensorflow.einsum.
- range(*args, **kwargs)
Wrapper around tensorflow.range using real numbers.
- static concatenate(*args, **kwargs)
Wrapper around tensorflow.concat.
- static repeat(*args, **kwargs)
Wrapper around tensorflow.repeat.
- static apply_fft(T, T_grid, leg_x)
Forward Fourier transformation for the spectral harmonics.
Notes
For the Gauss–Legendre grid used here, we have $N_{mathsf{lat}}=T_{mathsf{grid}}+1$ and $N_{mathsf{lon}}=2N_{mathsf{lat}}=2times(T_{mathsf{grid}}+1)$.
- Parameters:
T (int) – Truncature of the data in spectral space.
T_grid (int) – Truncature of the Gauss–Legendre grid.
leg_x (tensorflow.Tensor, shape (..., 2, Nlat, T+1)) – Legendre transform of $hat{x}$.
- Returns:
x – Variable $x$ in grid space.
- Return type:
tensorflow.Tensor, shape (…, Nlat, Nlon)
- static apply_ifft(T, T_grid, x)
Inverse Fourier transformation for the spectral harmonics.
Notes
For the Gauss–Legendre grid used here, we have $N_{mathsf{lat}}=T_{mathsf{grid}}+1$ and $N_{mathsf{lon}}=2N_{mathsf{lat}}=2times(T_{mathsf{grid}}+1)$.
- Parameters:
T (int) – Truncature of the data in spectral space.
T_grid (int) – Truncature of the Gauss–Legendre grid.
x (tensorflow.Tensor, shape (..., Nlat, Nlon)) – Variable $x$ in grid space.
- Returns:
leg_x – Legendre transform of $hat{x}$.
- Return type:
tensorflow.Tensor, shape (…, 2, Nlat, T+1)