Skip to content

Commit

Permalink
fixed issue with texts_from_folder reading in data from subfolders no…
Browse files Browse the repository at this point in the history
…t specified in classes argument and added maximum lr check to lrfinder
  • Loading branch information
amaiya committed Aug 16, 2019
1 parent 6258dd7 commit a02a4ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ Most recent releases are shown at the top. Each release shows:
- **Changed**: Additional parameters, changes to inputs or outputs, etc
- **Fixed**: Bug fixes that don't change documented behaviour

## 0.2.2 (2019-08-16)

### New:
- N/A

### Changed:
- Added check in ```ktrain.lroptimize.lrfinder``` to stop training if learning rate exceeds a fixed maximum,
which may happen when bad/dysfunctional model is supplied to learning rate finder.

### Fixed:
- In ```ktrain.text.data.texts_from_folder``` function, only subfolders specified in classes argument
are read in as training and validation data.

## 0.2.1 (2019-08-15)

### New:
Expand All @@ -15,7 +28,7 @@ Most recent releases are shown at the top. Each release shows:
- N/A

### Fixed:
- Fixed error related to validation_steps=None in call to fit_generator in ```ktrain.core``` on Google Colab
- Fixed error related to validation_steps=None in call to fit_generator in ```ktrain.core``` on Google Colab.


## 0.2.0 (2019-08-12)
Expand Down
5 changes: 5 additions & 0 deletions ktrain/lroptimize/lrfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def on_batch_end(self, batch, logs):
lr *= self.lr_mult
K.set_value(self.model.optimizer.lr, lr)

# stop if LR grows too large
if lr > 10.:
self.model.stop_training = True
return


def find(self, train_data, start_lr, lr_mult=1.01, max_epochs=None,
batch_size=U.DEFAULT_BS, workers=1, use_multiprocessing=False, verbose=1):
Expand Down
4 changes: 2 additions & 2 deletions ktrain/text/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def texts_from_folder(datadir, classes=None,
# read in training and test corpora
train_str = train_test_names[0]
test_str = train_test_names[1]
train_b = load_files(os.path.join(datadir, train_str), shuffle=True)
test_b = load_files(os.path.join(datadir, test_str), shuffle=False)
train_b = load_files(os.path.join(datadir, train_str), shuffle=True, categories=classes)
test_b = load_files(os.path.join(datadir, test_str), shuffle=False, categories=classes)
x_train = [x.decode('utf-8') for x in train_b.data]
x_test = [x.decode('utf-8') for x in test_b.data]
y_train = train_b.target
Expand Down
2 changes: 1 addition & 1 deletion ktrain/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__all__ = ['__version__']
__version__ = '0.2.1'
__version__ = '0.2.2'

0 comments on commit a02a4ca

Please sign in to comment.