chebyshev_expansion
Bases: transformation
The chebyshev data expansion function.
It performs the chebyshev expansion of the input vector, and returns the expansion result. The class inherits from the base expansion class (i.e., the transformation class in the module directory).
...
Notes
For input vector \(\mathbf{x} \in R^m\), its chebyshev expansion up to degree \(d\) can be represented as $$ \begin{equation} \kappa(\mathbf{x} | d) = \left[ T_1(\mathbf{x}), T_2(\mathbf{x}) \cdots, T_d(\mathbf{x}) \right] \in {R}^D, \end{equation} $$ where \(T_d(\mathbf{x})\) denotes the chebyshev expansion polynomial of \(\mathbf{x}\) of degree \(d\). The output dimension of chebyshev expansion will be \(D = m d\).
As to the specific representations of chebyshev polynomials, they can be defined recursively based on the lower-degree terms according to the following equations:
(1) Base chebyshev polynomial with degree \(d=0\) and \(d=1\): $$ \begin{equation} T_0(x) = 1 \text{, and } T_1(x) = x. \end{equation} $$
(2) Higher-degree chebyshev polynomial with \(d \ge 2\): $$ \begin{equation} T_d(x) = 2x \cdot T_{d-1}(x) - T_{d-2}(x). \end{equation} $$
By default, the input and output can also be processed with the optional pre- or post-processing functions in the chebyshev expansion function.
Attributes:
Name | Type | Description |
---|---|---|
name |
str, default = 'chebyshev_expansion'
|
Name of the expansion function. |
d |
int, default = 2
|
Degree of chebyshev expansion. |
Methods:
Name | Description |
---|---|
__init__ |
It performs the initialization of the expansion function. |
calculate_D |
It calculates the expansion space dimension D based on the input dimension parameter m. |
forward |
It implements the abstract forward method declared in the base expansion class. |
Source code in tinybig/expansion/recursive_expansion.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
__init__(name='chebyshev_polynomial_expansion', d=2, *args, **kwargs)
The initialization method of chebyshev expansion function.
It initializes a chebyshev expansion object based on the input function name. This method will also call the initialization method of the base class as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the chebyshev expansion function. |
'chebyshev_polynomial_expansion'
|
d
|
int
|
The degree of the chebyshev expansion function. |
2
|
Returns:
Type | Description |
---|---|
transformation
|
The chebyshev expansion function. |
Source code in tinybig/expansion/recursive_expansion.py
calculate_D(m)
The expansion dimension calculation method.
It calculates the intermediate expansion space dimension based on the input dimension parameter m. For the chebyshev expansion function, the expansion space dimension is determined by m and d, which can be represented as:
\[ D = m d. \]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The dimension of the input space. |
required |
Returns:
Type | Description |
---|---|
int
|
The dimension of the expansion space. |
Source code in tinybig/expansion/recursive_expansion.py
forward(x, device='cpu', *args, **kwargs)
The forward method of the data expansion function.
It performs the chebyshev data expansion of the input data and returns the expansion result according to the following equation: $$ \begin{equation} \kappa(\mathbf{x} | d) = \left[ T_1(\mathbf{x}), T_2(\mathbf{x}) \cdots, T_d(\mathbf{x}) \right] \in {R}^D. \end{equation} $$
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Tensor
|
The input data vector. |
required |
device
|
str
|
The device to perform the data expansion. |
'cpu'
|
Returns:
Type | Description |
---|---|
Tensor
|
The expanded data vector of the input. |