Merge branch 'master' of ssh://gogs@the-cake-is-a-lie.net:20022/jonas/NLP-LAB.git

This commit is contained in:
Carsten 2018-07-03 15:38:27 +02:00
commit dfba9ce9ae
2 changed files with 12 additions and 10 deletions

View File

@ -144,7 +144,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "d018a59d95fe45f2ae7be013a49b5900", "model_id": "a4899ee1720f4db4a136a96657f3283a",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
@ -495,7 +495,7 @@
" p = progress_indicator()\n", " p = progress_indicator()\n",
" \n", " \n",
" tr = stl.trainer(sdm=sdm, pm=pm)\n", " tr = stl.trainer(sdm=sdm, pm=pm)\n",
" tr.fit(progress_callback=p.update, batch_size=batch_size, n_epochs=n_epochs)\n", " tr.fit(progress_callback=p.update, batch_size=batch_size if batch_size > 0 else None, n_epochs=n_epochs)\n",
" \n", " \n",
"\n", "\n",
"# linking:\n", "# linking:\n",

View File

@ -633,6 +633,7 @@ class trainer(object):
named_steps[s].fit = lambda self, X, y=None: self named_steps[s].fit = lambda self, X, y=None: self
named_steps[s].fit_transform = named_steps[s].transform named_steps[s].fit_transform = named_steps[s].transform
if batch_size is not None:
for k in keras_batch_fitting_layer: for k in keras_batch_fitting_layer:
# forcing batch fitting on keras # forcing batch fitting on keras
disabled_keras_fits[k]=named_steps[k].fit disabled_keras_fits[k]=named_steps[k].fit
@ -640,7 +641,7 @@ class trainer(object):
named_steps[k].fit = lambda X, y: named_steps[k].train_on_batch(to_dense_if_sparse(X), y) # ← why has keras no sparse support on batch progressing!?!?! named_steps[k].fit = lambda X, y: named_steps[k].train_on_batch(to_dense_if_sparse(X), y) # ← why has keras no sparse support on batch progressing!?!?!
if batch_size is None: if batch_size is None:
self.pm.fit(X = self.sdm.X[:max_size], y = self.sdm.y[:max_size]) self.pm.fit(X = self.sdm.X[:max_size], y = self.sdm.y[:max_size], validation_split=0.1, epochs=n_epochs)
else: else:
n = len(self.sdm.X) // batch_size n = len(self.sdm.X) // batch_size
for i in range(n_epochs): for i in range(n_epochs):
@ -658,6 +659,7 @@ class trainer(object):
named_steps[s].fit = disabled_fits[s] named_steps[s].fit = disabled_fits[s]
named_steps[s].fit_transform = disabled_fit_transforms[s] named_steps[s].fit_transform = disabled_fit_transforms[s]
if batch_size is not None:
for k in keras_batch_fitting_layer: for k in keras_batch_fitting_layer:
named_steps[k].fit = disabled_keras_fits[k] named_steps[k].fit = disabled_keras_fits[k]