Skip to content

Commit 2a1f69b

Browse files
authored
Update to FluxTraining.jl v0.2.0 interfaces (#134)
* Revamp learning rate finder * Move notebook files * update `finetune!` and notebooks * Add weight decay to `fitonecycle!` * Add some docstrings
1 parent 54cf3b2 commit 2a1f69b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3774
-2901
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ test/Manifest.toml
33
docs/Manifest.toml
44
development/**
55
Manifest.toml
6-
docs/**/*.jld2
6+
**/*.jld2

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FilePathsBase = "0.9"
4545
FileTrees = "0.3"
4646
FixedPointNumbers = "0.8"
4747
Flux = "0.12"
48-
FluxTraining = "0.1, 0.2"
48+
FluxTraining = "0.2"
4949
JLD2 = "0.4"
5050
LearnBase = "0.3"
5151
MLDataPattern = "0.5"

docs/background/datapipelines.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using DataLoaders: batchviewcollated
2626
using FastAI
2727
using FastAI.Datasets
2828

29-
data = loadtaskdata(datasetpath("imagenette2-320"), ImageClasssification)
29+
data = loadtaskdata(datasetpath("imagenette2-320"), ImageClassification)
3030
method = ImageClassification(Datasets.getclassesclassification("imagenette2-320"), (224, 224))
3131

3232
# maps data processing over `data`
@@ -68,7 +68,7 @@ using FastAI
6868
using FastAI.Datasets
6969
using FluxTraining: fitbatchphase!
7070

71-
data = loadtaskdata(datasetpath("imagenette2-320"), ImageClasssification)
71+
data = loadtaskdata(datasetpath("imagenette2-320"), ImageClassification)
7272
method = ImageClassification(Datasets.getclassesclassification("imagenette2-320"), (224, 224))
7373

7474
learner = methodlearner(method, data, xresnet18())
@@ -100,7 +100,7 @@ using FastAI.Datasets
100100

101101
# Since loading times can vary per observation, we'll average the measurements over multiple observations
102102
N = 10
103-
data = datasubset(shuffleobs(loadtaskdata(datasetpath("imagenette2"), ImageClasssification), 1:N))
103+
data = datasubset(shuffleobs(loadtaskdata(datasetpath("imagenette2"), ImageClassification), 1:N))
104104
method = ImageClassification(Datasets.getclassesclassification("imagenette2-320"), (224, 224))
105105

106106
# Time it takes to load an `(image, class)` observation
@@ -132,13 +132,13 @@ If the data loading is still slowing down training, you'll probably have to spee
132132
For many computer vision tasks, you will resize and crop images to a specific size during training for GPU performance reasons. If the images themselves are large, loading them from disk itself can take some time. If your dataset consists of 1920x1080 resolution images but you're resizing them to 256x256 during training, you're wasting a lot of time loading the large images. *Presizing* means saving resized versions of each image to disk once, and then loading these smaller versions during training. We can see the performance difference using ImageNette since it comes in 3 sizes: original, 360px and 180px.
133133

134134
```julia
135-
data_orig = loadtaskdata(datasetpath("imagenette2"), ImageClasssification)
135+
data_orig = loadtaskdata(datasetpath("imagenette2"), ImageClassification)
136136
@time eachobsparallel(data_orig, buffered = false)
137137

138-
data_320px = loadtaskdata(datasetpath("imagenette2-320"), ImageClasssification)
138+
data_320px = loadtaskdata(datasetpath("imagenette2-320"), ImageClassification)
139139
@time eachobsparallel(data_320px, buffered = false)
140140

141-
data_160px = loadtaskdata(datasetpath("imagenette2-160"), ImageClasssification)
141+
data_160px = loadtaskdata(datasetpath("imagenette2-160"), ImageClassification)
142142
@time eachobsparallel(data_160px, buffered = false)
143143
```
144144

docs/data_containers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using FastAI.Datasets: datasetpath, loadtaskdata
1818

1919
NAME = "imagenette2-160"
2020
dir = datasetpath(NAME)
21-
data = loadtaskdata(dir, ImageClasssification)
21+
data = loadtaskdata(dir, ImageClassification)
2222
```
2323

2424
A data container is any type that holds observations of data and allows us to load them with `getobs` and query the number of observations with `nobs`:

docs/howto/augmentvision.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using FastAI
1010
using CairoMakie; CairoMakie.activate!(type="png")
1111

1212
dir = joinpath(datasetpath("dogscats"), "train")
13-
data = loadtaskdata(dir, ImageClasssification)
13+
data = loadtaskdata(dir, ImageClassification)
1414
classes = Datasets.getclassesclassification(dir)
1515
method = ImageClassification(classes, (100, 128))
1616
xs, ys = FastAI.makebatch(method, data, fill(4, 9))

docs/howto/logtensorboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ callbacks = [
3333
Metrics(accuracy)
3434
]
3535

36-
data = Datasets.loadtaskdata(Datasets.datasetpath("imagenette2-160"), ImageClasssification)
36+
data = Datasets.loadtaskdata(Datasets.datasetpath("imagenette2-160"), ImageClassification)
3737
method = ImageClassification(Datasets.getclassesclassification("imagenette2-160"), (160, 160))
3838
learner = methodlearner(method, data, Models.xresnet18(), callbacks...)
3939
fitonecycle!(learner, 5)

docs/interfaces.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ For visualizing observations and predictions using [Makie.jl](https://github.com
3333
- Required methods:
3434
- [`plotsample!`](#)
3535
- [`plotxy!`](#)
36+
- [`plotprediction!`](#)
3637
- Enables use of:
3738
- [`plotsamples`](#)
3839
- [`plotbatch`](#)

docs/introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
using FastAI
88
```
99

10-
On the [quickstart page](quickstart.ipynb), we showed how to train models on common tasks in a few lines of code:
10+
On the [quickstart page](../notebooks/quickstart.ipynb), we showed how to train models on common tasks in a few lines of code:
1111

1212
```julia
1313
using FastAI
1414

1515
path = datasetpath("imagenette2-160")
16-
dataset = loadtaskdata(path, ImageClasssification)
16+
dataset = loadtaskdata(path, ImageClassification)
1717
method = ImageClassification(Datasets.getclassesclassification("imagenette2-160"), (160, 160))
1818
dls = methoddataloaders(dataset, method, 16)
1919
model = methodmodel(method, Models.xresnet18())
@@ -28,7 +28,7 @@ Let's unpack each line.
2828
{cell=main}
2929
```julia
3030
path = datasetpath("imagenette2-160")
31-
dataset = loadtaskdata(path, ImageClasssification)
31+
dataset = loadtaskdata(path, ImageClassification)
3232
```
3333

3434
These two lines download and load the [ImageNette](https://github.com/fastai/imagenette) image classification dataset, a small subset of ImageNet with 10 different classes. `dataset` is a [data container](data_containers.md) that can be used to load individual observations, here of images and the corresponding labels. We can use `getobs(dataset, i)` to load the `i`-th observation and `nobs` to find out how many observations there are.

docs/learning_methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Before we get started, let's load up a [data container](data_containers.md) that
2727
using FastAI
2828
using FastAI.Datasets
2929
DATASET = "imagenette2-160"
30-
data = Datasets.loadtaskdata(Datasets.datasetpath(DATASET), ImageClasssification)
30+
data = Datasets.loadtaskdata(Datasets.datasetpath(DATASET), ImageClassification)
3131
image, class = getobs(data, 1)
3232
image
3333
```

docs/methods/imageclassification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
using CairoMakie
2020
using FastAI
2121
dir = joinpath(datasetpath("dogscats"), "train")
22-
data = loadtaskdata(dir, ImageClasssification)
22+
data = loadtaskdata(dir, ImageClassification)
2323
samples = [getobs(data, i) for i in rand(1:nobs(data), 9)]
2424
classes = Datasets.getclassesclassification(dir)
2525
method = ImageClassification(classes, (128, 128))

0 commit comments

Comments
 (0)