Commit e89a5613 authored by Yuxin Wu's avatar Yuxin Wu

acc.count

parent 13f62fdc
......@@ -66,7 +66,7 @@ class MultiProcessDatasetPredictor(DatasetPredictorBase):
Run prediction in multiprocesses, on either CPU or GPU. Mix mode not supported.
:param nr_proc: number of processes to use
:param use_gpu: use GPU or CPU.
nr_proc cannot be larger than the total number of GPUs available
if GPU, then nr_proc cannot be larger than the total number of GPUs available
in CUDA_VISIBLE_DEVICES or in the system.
"""
assert config.return_input == False, "return_input not supported for MultiProcessDatasetPredictor"
......
......@@ -31,10 +31,15 @@ class Discretizer1D(Discretizer):
class UniformDiscretizer1D(Discretizer1D):
def __init__(self, minv, maxv, spacing):
"""
:params minv: minimum value of the first bin
:params maxv: maximum value of the last bin
:param spacing: width of a bin
"""
self.minv = float(minv)
self.maxv = float(maxv)
self.spacing = float(spacing)
self.nr_bin = np.ceil((self.maxv - self.minv) / self.spacing)
self.nr_bin = int(np.ceil((self.maxv - self.minv) / self.spacing))
def get_nr_bin(self):
return self.nr_bin
......@@ -51,6 +56,8 @@ class UniformDiscretizer1D(Discretizer1D):
0, self.nr_bin - 1))
def get_distribution(self, v, smooth_factor=0.05, smooth_radius=2):
""" return a smoothed one-hot distribution of the sample v.
"""
b = self.get_bin(v)
ret = np.zeros((self.nr_bin, ), dtype='float32')
ret[b] = 1.0
......
......@@ -52,6 +52,10 @@ class Accuracy(object):
return 0
return self.corr * 1.0 / self.tot
@property
def count(self):
return self.tot
class BinaryStatistics(object):
"""
......
......@@ -92,6 +92,6 @@ def get_dataset_dir(name):
assert os.path.isdir(d)
else:
d = os.path.join(os.path.dirname(__file__), '..', 'dataflow', 'dataset')
logger.info("TENSORPACK_DATASET not set, using {} to keep dataset.".format(d))
logger.info("TENSORPACK_DATASET not set, using {} for dataset.".format(d))
return os.path.join(d, name)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment