- refactored Status
- added update interval
This commit is contained in:
+4
-2
@@ -12,11 +12,11 @@ def cv_show(name: str, vec: np.array, shape):
|
|||||||
|
|
||||||
class MyStatus(Status):
|
class MyStatus(Status):
|
||||||
def __init__(self, _stack: StackDeep, _batch: np.ndarray):
|
def __init__(self, _stack: StackDeep, _batch: np.ndarray):
|
||||||
Status.__init__(self)
|
Status.__init__(self, update_interval=2)
|
||||||
self.stack = _stack
|
self.stack = _stack
|
||||||
self.batch = _batch
|
self.batch = _batch
|
||||||
|
|
||||||
def on_change(self, status: dict) -> bool:
|
def on_report(self, status: dict) -> bool:
|
||||||
# Show reconstruction
|
# Show reconstruction
|
||||||
# Shape of training vector
|
# Shape of training vector
|
||||||
shape = self.stack.from_index(0).shape[0:2] + (1,)
|
shape = self.stack.from_index(0).shape[0:2] + (1,)
|
||||||
@@ -25,6 +25,8 @@ class MyStatus(Status):
|
|||||||
img = self.stack.pass_down_up(self.batch[n,:])
|
img = self.stack.pass_down_up(self.batch[n,:])
|
||||||
cv_show("img", img, shape)
|
cv_show("img", img, shape)
|
||||||
cv.waitKeyEx(1)
|
cv.waitKeyEx(1)
|
||||||
|
|
||||||
|
Status.print_status(status)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def read_armadillo(filename: str) -> np.ndarray:
|
def read_armadillo(filename: str) -> np.ndarray:
|
||||||
|
|||||||
+19
-10
@@ -1,6 +1,18 @@
|
|||||||
class Status:
|
class Status:
|
||||||
def __init__(self):
|
def __init__(self, update_interval=10):
|
||||||
self.progress = -1
|
self.progress = -1
|
||||||
|
self.update_interval = update_interval
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def print_status(status: dict):
|
||||||
|
print("-------------------------------------------")
|
||||||
|
for key in status.keys():
|
||||||
|
value = status[key]['value']
|
||||||
|
unit = status[key]['unit']
|
||||||
|
if isinstance(value, float):
|
||||||
|
print(f"{key} : {value:0.6f}{unit}")
|
||||||
|
else:
|
||||||
|
print(f"{key} : {value}{unit}")
|
||||||
|
|
||||||
def on_change(self, status: dict) -> bool:
|
def on_change(self, status: dict) -> bool:
|
||||||
if status == {}:
|
if status == {}:
|
||||||
@@ -8,14 +20,11 @@ class Status:
|
|||||||
|
|
||||||
if "progress" in status.keys():
|
if "progress" in status.keys():
|
||||||
progress = status["progress"]['value']
|
progress = status["progress"]['value']
|
||||||
if self.progress < 0 or progress - self.progress >= 10:
|
if self.progress < 0 or progress - self.progress >= self.update_interval:
|
||||||
self.progress = progress
|
self.progress = progress
|
||||||
print("-------------------------------------------")
|
self.on_report(status=status)
|
||||||
for key in status.keys():
|
|
||||||
value = status[key]['value']
|
return True
|
||||||
unit = status[key]['unit']
|
|
||||||
if isinstance(value, float):
|
def on_report(self, status: dict) -> bool:
|
||||||
print(f"{key} : {value:0.6f}{unit}")
|
|
||||||
else:
|
|
||||||
print(f"{key} : {value}{unit}")
|
|
||||||
return True
|
return True
|
||||||
Reference in New Issue
Block a user