Skip to content
Snippets Groups Projects

More efficient 'tell_many'

Merged Bas Nijholt requested to merge efficient_tell_many into master
All threads resolved!
Compare and Show latest version
1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
@@ -132,7 +132,11 @@ class Learner1D(BaseLearner):
if self._vdim is None:
if self.data:
y = next(iter(self.data.values()))
self._vdim = len(np.squeeze(y))
try:
self._vdim = len(np.squeeze(y))
except TypeError:
# Means we are taking the length of a float
self._vdim = 1
else:
return 1
return self._vdim
@@ -289,7 +293,7 @@ class Learner1D(BaseLearner):
self.update_losses(x, real=False)
def tell_many(self, xs, ys):
if len(xs) < max(2, 0.5 * len(self.data)):
if len(xs) > 0.5 * len(self.data) and len(xs) > 2:
# Only run this more efficient method if there are
# at least 2 points and the amount of points added are
# at least half of the number of points already in 'data'.
Loading