Fastai_v1, adding features

In think there is a bug in add_cyclic_datepart functionality. When add_cyclic_datepart is used on DataFrame with indexing scheme other than standard values 0,1,2,…n it produces data frame with additional empty row(s). Below is a code to reproduce bug:

from fastai.tabular.transform import add_cyclic_datepart
import pandas as pd

df = pd.DataFrame({"dat": pd.date_range('2019-03-01', '2019-03-05')}, index=range(4,9))
print("Original df\n", df)

df_mod = add_cyclic_datepart(df, 'dat')
print("Modified df\n", df_mod)

Result of running this code is that data frame df_mod contains 4 additional rows with NaN values (9 rows in total vs 5 rows in original data frame df).

Versioning of https://docs.fast.ai/

Over the past few days, I stumbled a dozen times across issues of being unable to reproduce fast.ai code examples, in some cases even from the official API documentation and in virtually all cases it came down to a version mismatches between the used API and the referenced documentation. I understand that the fast.ai API evolves really fast and the official documentation on the website may lag a bit, and that’s okay.

However, as a workaround of the fast changes, please add an API version number to the web API documentation.

Example:

https://1.0.46/docs.fast.ai/
https://0.74/docs.fast.ai/
etc

Also, it would be marvelous to tag obsolete methods with the @deprecated decorator for some time with a reference what to use instead before removing them. Over the past few days, I had to fix so many “no method” glitches exactly because the underlying method has been removed or moved in a release after the code example was written and a tiny deprecated annotation with a hint what to use instead would have been saved some time and hazzles.

That being said, the fast.ai 1.0+ API is pretty amazing so thanks for all the good work.

The docs are always up to date with the latest release (we try to keep it up to date with master but there might be a delay). It’s tricky to have frozen versions of docs but we can add a version flag to say what it’s supposed to run with.

As for the deprecation warnings, we are trying to get better with that. The last breaking changes (create_cnn -> cnn_learner and co) were all elft with the old function deprecated. i didn’t know there was a decorator that did that automatically, will check that!

Thank you @sgugger. Just adding a version flag to the docs already helps a lot to troubleshoot.

As for the @deprecated decorator, I think it’s part of the standard lib[1] and works as expected. Here are some code examples:

Thanks for taking a lot and for all the good work.

Would it be a good idea to make learn.fit automatically use the learning rate finder?

We could have a flag like LR_range_test=True which would automatically set lr = lrs[losses.index(min(losses))] / 10.

It could further automate the learning rate finder process and might be better than defaults.lr = slice(3e-3).

Is there a plan to add CoordConv networks to fast.ai?

According to the authors:

“CoordConv models have 10-100 times fewer parameters, train in seconds rather than over an hour (150 times faster) as needed for the best-performing standard CNNs.”

Sample Pytorch implementation:


Paper:

Blog
https://eng.uber.com/coordconv/
Translation invariance experiment

2 Likes

Or maybe even implementing a moving average for the derivative of loss with respect to learning rate, and use the argmin of that (I read this on a Medium post).

Hi Ricardo,
I haven’t used this yet, but I am really excited about it, especially for my area of interest - NLP in medicine. Google has a great example of the impact of this “interpretation” on page 6 of this article: https://arxiv.org/ftp/arxiv/papers/1801/1801.07860.pdf
This example showed why the network thought that the patient was likely to die, and the highlighted phrases were right on target (cancer, malignant pleural effusion, etc).
I have long felt that the barriers to success of DL in medicine will be

  • Not enough labels - ULMFiT solves that
  • Providers don’t trust black-box prediction - you are making interpretation easy for all of us!

Thank you for your contribution!
Dana

1 Like

Thanks for reporting this issue. I’ll try to send a fix as soon as possible.

PR sent. It’s a quick fix in case you want to patch it yourself locally for now: https://github.com/fastai/fastai/pull/1924/commits/b48423254c1a54a1fcef4346825997eca2c08dee

Per class metrics and multi-label metrics

Often, in a classification problem, papers will provide a table showing metrics by class, it’s useful to compare results to industry benchmarks and can also help gain insights on which class is underperforming.
Is there a way to do this already? If not I’m willing to contribute a PR

Similarly, for multi-label problems, it would be great to be able to compute the traditional metrics directly (Precision, recall, FBeta, etc.), most metrics in the library currently do not work for multi-label scenarios.
Eventually I would like to combine these 2 features (multi-label, per class metrics).

@herrmann Have you found any particular impact on accuracy when using the sine and cosine parts of modular components of date/time cycles?

What exactly is the underlying motivation?

I haven’t seen anything like this before so I am really curious to learn why that might be a good idea to do?

Hi, can I submit a PR for returning results from functions show_results instead of just displaying them?
The reason is that I want to do a callback for logging losses, metrics & results at each epoch.

Option 1 (raw data):

  • return (xs, ys, zs), whether it is text or images

Option 2 (formatted data):

  • text: return pd.DataFrame
  • images: return plt

I’m a bit more in favor of option 2 as we benefit from the formatting done by the show_results functions.

It sounds like you want something that is different from show_results, which, as its name indicates, shows things. Just copy-paste the code that is in show_results and remove the lines you don’t need .

Actually I just want to keep a handle of results displayed (it could even be just the html).

I could have a log_results function but I’ll need to keep it in sync with all the show_results (if they get updated). I would also need to copy the code from show_xyzs as it is used when the data is tabular.

Right now, it is the best workaround I found for creating a logging callback that would save sample predictions during training while still benefiting from existing functions and have a minimal amount of code (it’s just about adding a return statement in show_results and show_xyzs).

At the moment, show_results does not return anything so it would not impact any existing code that doesn’t make use of it.

Here are the changes I am suggesting: github commit

This will allow us to build upon callbacks such as CSVLogger and add sample predictions to see how they evolve during training, whether logged locally or online (which is what I am working on).

QRNN float16 support - see bfarzin’s post.

Anyone has an idea how to change relevant CUDA code to make it work?

QRNN work in FP16 since v1.0.56

1 Like

Thank you so much for a wonderful course and a great package.

A colleague and I are working on tabular data, and would like to specify particular activation functions for each layer in the model. Currently it seems that it is not possible to do in an easy way.

Would it be interesting to add this and would you accept a pull request, if I created it?

Can we make the prediction tasks threadsave? For example this one:
https://docs.fast.ai/text.learner.html#LanguageLearner.predict
If I run that function to many times at the same time, the function throws internal errors.
I do not know enough about how it works to know if it is possible to make it static or if there is another way to make it threadsave.
The Use-Case: Use the classifiers on a Server taking multiple requests.