diff --git a/spearmint/tasks/base_task.py b/spearmint/tasks/base_task.py index 34c183a..f6b2a72 100755 --- a/spearmint/tasks/base_task.py +++ b/spearmint/tasks/base_task.py @@ -243,7 +243,7 @@ def variables_config_to_meta(self, variables_config): def paramify_and_print(self, data_vector, left_indent=0, indent_top_row=False): params = self.paramify(data_vector) indentation = ' '*left_indent - + if indent_top_row: sys.stderr.write(indentation) sys.stderr.write('NAME TYPE VALUE\n') @@ -263,7 +263,7 @@ def paramify_and_print(self, data_vector, left_indent=0, indent_top_row=False): if i == 0: sys.stderr.write(format_str % (indentation, param_name, param['type'], param['values'][i])) else: - sys.stderr.write(format_str % (indentation, '', param['values'][i])) + sys.stderr.write(format_str % (indentation, '', '', param['values'][i])) # Converts a vector in input space to the corresponding dict of params def paramify(self, data_vector): @@ -284,7 +284,7 @@ def paramify(self, data_vector): params[name]['values'].append(vdict['options'][data_vector[ind].argmax(0)]) else: raise Exception('Unknown parameter type.') - + return params # Converts a dict of params to the corresponding vector in puts space @@ -334,7 +334,7 @@ def to_unit(self, V): U = np.squeeze(U) return U - + def from_unit(self, U): if U.shape[0] == 0: return np.array([]) @@ -368,14 +368,14 @@ def from_unit(self, U): raise Exception("Unknown variable type: %s" % variable['type']) if squeeze: - V = np.squeeze(V) + V = np.ma.atleast_1d(np.squeeze(V)) return V # Convert primitive types to the unit hypercube def int_to_unit(self, v, vmin, vmax): unit = (np.double(v) - vmin) / (vmax - vmin) - + # Make sure we are not over bounds try: unit[unit > 1] = 1 @@ -389,7 +389,7 @@ def int_to_unit(self, v, vmin, vmax): def float_to_unit(self, v, vmin, vmax): unit = (np.double(v) - vmin) / (vmax - vmin) - + # Make sure we are not over bounds try: unit[unit > 1] = 1.0