-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Tidy up the rocket transformers #1699
Comments
after #1781, next issue is to allow variable length. #1746 PR does it by taking numba inside the loop, but it slows it down unacceptably. An alternative, which is already in Rocket, is not to give types in njit arguments. Surprisingly, Rocket does not do this @njit(fastmath=True, cache=True)
def _apply_kernel_univariate(X, weights, length, bias, dilation, padding):
n_timepoints = len(X)
output_length = (n_timepoints + (2 * padding)) - ((length - 1) * dilation) whereas minirocket does @njit(
"float32[:,:](float32[:,:],Tuple((int32[:],int32[:],int32[:],int32[:],float32["
":])), int32[:,:])",
fastmath=True,
parallel=True,
cache=True,
)
def _static_transform_uni(X, parameters, indices): without them, its much easier to use multivariate, but crucially need to assess any performance hit. So some timing experiments
based on these results, either remove type annotation and adapt to lists of numpy or add them and use split functions |
Code to test 1 and 2, including direct code without def timing_experiment_n_cases_main():
import time
# Build numba functions
X = np.random.random(size=(10, 1, 100)).astype(np.float32)
r = MiniRocket(random_state=0)
p1 = r.fit_transform(X)
r2 = MiniRocket(random_state=0)
p2= r2.fit_transform(X)
r3 =BadPlaceMiniRocket(random_state=0)
r4 = BadPlaceMiniRocketMultivariate(random_state=0)
p3= r3.fit_transform(X)
p4=r4.fit_transform(X)
for i in range(500,31000,500):
X1 = make_example_3d_numpy(n_cases=i, n_channels=1, n_timepoints=500,
return_y=False).astype(np.float32)
X2 = make_example_3d_numpy(n_cases=i, n_channels=5, n_timepoints=100,
return_y=False).astype(np.float32)
from aeon.transformations.collection.convolution_based._minirocket import \
_static_fit, _static_transform_uni, _static_transform_multi
start = time.time()
r.fit_transform(X1)
t1 = time.time() - start
start = time.time()
r.fit_transform(X2)
t2 = time.time() - start
start = time.time()
p1=_static_fit(X1)
X_= X1.squeeze(1)
_static_transform_uni(X_,p1,MiniRocket._indices)
t3 = time.time() - start
start = time.time()
p1=_static_fit(X2)
_static_transform_multi(X2,p1,MiniRocket._indices)
t4 = time.time() - start
start = time.time()
r2._fit_transform(X1)
t5 = time.time() - start
start = time.time()
r2._fit_transform(X2)
t6 = time.time() - start
start = time.time()
r3.fit_transform(X1)
t7 = time.time() - start
start = time.time()
r4.fit_transform(X2)
t8 = time.time() - start
print(i,",",t1,",",t2,",",t3,",",t4,",",t5,",",t6,",",t7,",",t8) |
so if anything adding type checks makes it a bit slower. <style> </style>
|
Describe the feature or idea you want to propose
Its time to tidy up the convolutional transformers, will collate all issues here and make tasks for smaller PRs. Replaces #208
To Do
Done
The text was updated successfully, but these errors were encountered: