Skip to content
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

InceptionTime Model for Time Series #256

Merged
merged 12 commits into from Sep 27, 2022
Merged

Conversation

codeboy5
Copy link
Contributor

This PR will contain the implementation of InceptionTime Model and it's use for classification and regression task.

Some of the commits from the PR #253 are also in this PR, but will take care of them when that PR is merged.

FastTimeSeries/src/models/InceptionTime.jl Outdated Show resolved Hide resolved
FastTimeSeries/src/models/InceptionTime.jl Outdated Show resolved Hide resolved
FastTimeSeries/src/models.jl Outdated Show resolved Hide resolved
@codeboy5
Copy link
Contributor Author

Have to fix a couple of issues with the residual part.

@codeboy5
Copy link
Contributor Author

Hey @ToucheSir @darsnack @lorenzoh,
So If i do use the residual layers, I seem to be getting a size mismatch during the backprop. The forward pass and loss computation works fine. I am still trying to figure out where exactly the issue is. If you see any issues by just taking a quick look at the code, it would help. Thanks

@ToucheSir
Copy link
Member

Try building up your model bit-by-bit and checking for size mismatches on each submodule with a dummy input. Flux.outputsize can also be very useful here.

@codeboy5
Copy link
Contributor Author

Try building up your model bit-by-bit and checking for size mismatches on each submodule with a dummy input. Flux.outputsize can also be very useful here.

Yeah I tried doing that. I dont understand how the forward pass works fine but the backprop gives an error. Will figure it out.

@ToucheSir
Copy link
Member

Since only InceptionModule has been ported over so far, you could save some time by just testing with that. Feel free to drop a MWE and stacktrace here if you get stuck.

InceptionBlock will need to receive the same treatment at some point. One resource which might help are the 2D Inception image models in Metalhead. Those make extensive use of Flux container layers.

@codeboy5
Copy link
Contributor Author

The code can be tested with the following snipet :-

data, blocks = load(datarecipes()["natops"]);
task = TSClassificationSingle(blocks, data);
traindl, validdl = taskdataloaders(data, task, 16);
callbacks = [ToGPU(), Metrics(accuracy)];
model = FastTimeSeries.Models.InceptionTime(24, 6);
learner = Learner(model, tasklossfn(task); data=(traindl, validdl), optimizer=ADAM(), callbacks = [ToGPU(), Metrics(accuracy)]);
fitonecycle!(learner, 10, 0.01)

Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple comments on the WIP here. Mostly looks good and I'm glad you can get it training :)

FastTimeSeries/src/models/InceptionTime.jl Outdated Show resolved Hide resolved
bottleneck_block = bottleneck ? Conv1d(ni, nf, 1, bias = false) : identity

convs_layers =
[Conv1d(bottleneck ? nf : ni, nf, ks[i], bias = false) for i in range(1, stop = 3)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to have Conv1d be lowercase conv1d, but that's a minor thing.

FastTimeSeries/src/models/InceptionTime.jl Outdated Show resolved Hide resolved
@codeboy5
Copy link
Contributor Author

codeboy5 commented Sep 5, 2022

Hey guys, so the model is working for regression task too now, will push the notebook in a while.

@ToucheSir
Copy link
Member

I have some suggestions for the notebook, but that can wait for a follow-up PR. Will try to have a look at the model again in the next couple of days.

FastTimeSeries/src/models/InceptionTime.jl Outdated Show resolved Hide resolved
inception = []
shortcut = []

for d in range(1, stop = depth)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still many wild ranges floating around ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will fix that in the next commit.

FastTimeSeries/src/models/RNN.jl Outdated Show resolved Hide resolved
FastTimeSeries/src/models/InceptionTime.jl Outdated Show resolved Hide resolved
Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM once docstrings are added and commented code is restored/removed.

@codeboy5
Copy link
Contributor Author

Mostly LGTM once docstrings are added and commented code is restored/removed.

Hey, will push the docstrings today. This PR should be ready to go after it unless we want to further improve something. We can also discuss the future steps in our next biweekly.

Copy link
Member

@ToucheSir ToucheSir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the delay on reviewing this. Let's get it merged.

@ToucheSir ToucheSir merged commit 5a6d021 into FluxML:master Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants