Skip to content

Commit

Permalink
Added version/get_() to dataset; allow Experiment to have single valu…
Browse files Browse the repository at this point in the history
…e option; WIP: net.evaluate(verbose=-1)
  • Loading branch information
dsblank committed Sep 17, 2018
1 parent 474caf4 commit 714b30e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
19 changes: 18 additions & 1 deletion conx/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ def __init__(self,
name=None,
description=None,
input_shapes=None,
target_shapes=None):
target_shapes=None,
version="1.0.0"):
"""
Dataset constructor.
Expand All @@ -660,6 +661,7 @@ def __init__(self,
self.warn_categories = {}
self.network = network
self.name = name
self.version = version
self.description = description
self.DATASETS = {name: function for (name, function) in
inspect.getmembers(conx.datasets, inspect.isfunction)}
Expand All @@ -669,6 +671,21 @@ def __init__(self,
if target_shapes is not None:
self._target_shapes = target_shapes

def get_id(self):
"""
Get the version number of the dataset.
>>> ds = Dataset(name="Test", version="1.0.0")
>>> ds.get_id()
'Test-1.0.0'
>>> ds.version = "2.0.1"
>>> ds.get_id()
'Test-2.0.1'
"""
return "%s-%s" % (self.name, self.version)

def __getattr__(self, item):
"""
Construct a virtual Vector for easy access to internal
Expand Down
7 changes: 6 additions & 1 deletion conx/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ def reset(self, clear=False, **overrides):

def evaluate(self, batch_size=None, show=False, show_inputs=True, show_targets=True,
kverbose=0, sample_weight=None, steps=None, tolerance=None, force=False,
max_col_width=15, select=None):
max_col_width=15, select=None, verbose=0):
"""
Evaluate the train and/or test sets.
Expand Down Expand Up @@ -917,6 +917,9 @@ def evaluate(self, batch_size=None, show=False, show_inputs=True, show_targets=T
for i in range(len(self.model.metrics_names)):
print(" %15s: %10s" % (self.model.metrics_names[i], self.pf(results[i])))
print(" %15s: %10s" % ("Total", num_test))
if verbose == -1:
## FIXME: combine results from train and test
return results
else: # all (or select data):
if select is None:
print("All Data Results:")
Expand All @@ -937,6 +940,8 @@ def evaluate(self, batch_size=None, show=False, show_inputs=True, show_targets=T
for i in range(len(self.model.metrics_names)):
print(" %15s: %10s" % (self.model.metrics_names[i], self.pf(results[i])))
print(" %15s: %10s" % ("Total", len(self.dataset)))
if verbose == -1:
return results

def _evaluate_range(self, slice, show_inputs, show_targets, batch_size,
kverbose, sample_weight, steps, force, max_col_width):
Expand Down
7 changes: 4 additions & 3 deletions conx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,9 +2221,9 @@ class Experiment():
... return category, net
>>> exp = Experiment("XOR")
>>> exp.run(function,
... epochs=[5],
... epochs=5,
... accuracy=[0.8],
... tolerance=[0.2],
... tolerance=0.2,
... optimizer=["adam", "sgd"],
... activation=["sigmoid", "relu"],
... dir="/tmp/")
Expand Down Expand Up @@ -2287,7 +2287,8 @@ def run(self, function, trials=1, dir="./", save=True, cache=False, **options):
"""
options = sorted(options.items())
keys = [option[0] for option in options]
values = [option[1] for option in options]
values = [option[1] if isinstance(option[1], (tuple, list)) else [option[1]]
for option in options]
for trial in range(1, trials + 1):
count = 1
for combination in itertools.product(*values):
Expand Down

0 comments on commit 714b30e

Please sign in to comment.