Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiya committed Jun 5, 2019
2 parents ec6d0d3 + 8b60d8a commit ba186c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ 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.1.8 (2019-06-04)

### New:
- N/A

### Changed:
- N/A

### Fixed:
- ```Learner.set_weight_decay``` now works correctly


## 0.1.7 (2019-05-24)

### New:
Expand Down
3 changes: 3 additions & 0 deletions ktrain/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ def set_weight_decay(self, wd=0.005):
for layer in self.model.layers:
if hasattr(layer, 'kernel_regularizer'):
layer.kernel_regularizer= regularizers.l2(wd)
layer.add_loss(regularizers.l2(wd)(layer.kernel))
if hasattr(layer, 'bias_regularizer'):
layer.bias_regularizer= regularizers.l2(wd)
layer.add_loss(regularizers.l2(wd)(layer.bias))
self._recompile()
return


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.1.7'
__version__ = '0.1.8'
51 changes: 28 additions & 23 deletions tutorial-A1-additional-tricks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0 (trainable=True) : <keras.layers.embeddings.Embedding object at 0x7fef21ba1630>\n",
"1 (trainable=True) : <keras.layers.pooling.GlobalAveragePooling1D object at 0x7fef615d2978>\n",
"2 (trainable=True) : <keras.layers.core.Dense object at 0x7fef21ba1a20>\n"
"0 (trainable=True) : <keras.layers.embeddings.Embedding object at 0x7f77fa4adcf8>\n",
"1 (trainable=True) : <keras.layers.pooling.GlobalAveragePooling1D object at 0x7f77fa4adfd0>\n",
"2 (trainable=True) : <keras.layers.core.Dense object at 0x7f783cc27fd0>\n"
]
}
],
Expand Down Expand Up @@ -198,9 +198,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0 (trainable=True) : <keras.layers.embeddings.Embedding object at 0x7ff69cc4d9b0>\n",
"1 (trainable=True) : <keras.layers.pooling.GlobalAveragePooling1D object at 0x7ff69cc1c128>\n",
"2 (trainable=True, wd=None) : <keras.layers.core.Dense object at 0x7ff69cc1c160>\n"
"0 (trainable=True) : <keras.layers.embeddings.Embedding object at 0x7f65e8e2bd68>\n",
"1 (trainable=True) : <keras.layers.pooling.GlobalAveragePooling1D object at 0x7f65e8e2beb8>\n",
"2 (trainable=True, wd=None) : <keras.layers.core.Dense object at 0x7f65e8e2be80>\n"
]
}
],
Expand All @@ -214,7 +214,7 @@
"metadata": {},
"outputs": [],
"source": [
"learner.set_weight_decay(0.1)"
"learner.set_weight_decay(1e-3)"
]
},
{
Expand All @@ -225,7 +225,7 @@
{
"data": {
"text/plain": [
"[array(0.1, dtype=float32)]"
"[array(0.001, dtype=float32)]"
]
},
"execution_count": 7,
Expand All @@ -246,9 +246,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0 (trainable=True) : <keras.layers.embeddings.Embedding object at 0x7ff69cc4d9b0>\n",
"1 (trainable=True) : <keras.layers.pooling.GlobalAveragePooling1D object at 0x7ff69cc1c128>\n",
"2 (trainable=True, wd=0.1) : <keras.layers.core.Dense object at 0x7ff69cc1c160>\n"
"0 (trainable=True) : <keras.layers.embeddings.Embedding object at 0x7f65e8e2bd68>\n",
"1 (trainable=True) : <keras.layers.pooling.GlobalAveragePooling1D object at 0x7f65e8e2beb8>\n",
"2 (trainable=True, wd=0.001) : <keras.layers.core.Dense object at 0x7f65e8e2be80>\n"
]
}
],
Expand All @@ -258,7 +258,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -267,30 +267,35 @@
"text": [
"\n",
"\n",
"begin training using onecycle policy with max lr of 0.005...\n",
"begin training using triangular learning rate policy with max lr of 0.005...\n",
"Train on 25000 samples, validate on 25000 samples\n",
"Epoch 1/3\n",
"25000/25000 [==============================] - 6s 251us/step - loss: 0.5552 - acc: 0.7462 - val_loss: 0.3613 - val_acc: 0.8609\n",
"Epoch 2/3\n",
"25000/25000 [==============================] - 6s 244us/step - loss: 0.2686 - acc: 0.8970 - val_loss: 0.2907 - val_acc: 0.8841\n",
"Epoch 3/3\n",
"25000/25000 [==============================] - 6s 246us/step - loss: 0.1738 - acc: 0.9406 - val_loss: 0.2780 - val_acc: 0.8902\n"
"Epoch 1/6\n",
"25000/25000 [==============================] - 7s 270us/step - loss: 0.5387 - acc: 0.7776 - val_loss: 0.4369 - val_acc: 0.8681\n",
"Epoch 2/6\n",
"25000/25000 [==============================] - 6s 255us/step - loss: 0.3808 - acc: 0.8934 - val_loss: 0.3947 - val_acc: 0.8810\n",
"Epoch 3/6\n",
"25000/25000 [==============================] - 6s 254us/step - loss: 0.3363 - acc: 0.9124 - val_loss: 0.3755 - val_acc: 0.8861\n",
"Epoch 4/6\n",
"25000/25000 [==============================] - 6s 254us/step - loss: 0.3081 - acc: 0.9220 - val_loss: 0.3623 - val_acc: 0.8881\n",
"Epoch 5/6\n",
"25000/25000 [==============================] - 6s 257us/step - loss: 0.2867 - acc: 0.9319 - val_loss: 0.3539 - val_acc: 0.8891\n",
"Epoch 6/6\n",
"25000/25000 [==============================] - 6s 257us/step - loss: 0.2703 - acc: 0.9363 - val_loss: 0.3469 - val_acc: 0.8905\n"
]
},
{
"data": {
"text/plain": [
"<keras.callbacks.History at 0x7ff697cf0550>"
"<keras.callbacks.History at 0x7f65df4c8278>"
]
},
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"learner.set_model(get_model())\n",
"learner.fit_onecycle(0.005, 3)"
"learner.autofit(0.005, 6)"
]
},
{
Expand Down

0 comments on commit ba186c8

Please sign in to comment.