MCPcopy Create free account
hub / github.com/DingLei14/WiCoNet / AverageMeter

Class AverageMeter

utils/utils.py:114–146  ·  view source on GitHub ↗

Computes and stores the average and current value

Source from the content-addressed store, hash-verified

112
113
114class AverageMeter(object):
115 """Computes and stores the average and current value"""
116 def __init__(self):
117 self.initialized = False
118 self.val = None
119 self.avg = None
120 self.sum = None
121 self.count = None
122
123 def initialize(self, val, count, weight):
124 self.val = val
125 self.avg = val
126 self.count = count
127 self.sum = val * weight
128 self.initialized = True
129
130 def update(self, val, count=1, weight=1):
131 if not self.initialized:
132 self.initialize(val, count, weight)
133 else:
134 self.add(val, count, weight)
135
136 def add(self, val, count, weight):
137 self.val = val
138 self.count += count
139 self.sum += val * weight
140 self.avg = self.sum / self.count
141
142 def value(self):
143 return self.val
144
145 def average(self):
146 return self.avg
147
148def ImageValStretch2D(img):
149 img = img*255

Callers 10

trainFunction · 0.90
validateFunction · 0.90
trainFunction · 0.90
validateFunction · 0.90
predictFunction · 0.90
trainFunction · 0.90
validateFunction · 0.90
predictFunction · 0.90
AccEvalFunction · 0.90
predictFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected