[Rbm]
- abort by user [q] - cycle through training patetrn by [+],[-] keys [Status] - improved report interval - added on_report(): called every report iterval
This commit is contained in:
+19
-8
@@ -15,19 +15,30 @@ class MyStatus(Status):
|
|||||||
Status.__init__(self, update_interval=2)
|
Status.__init__(self, update_interval=2)
|
||||||
self.stack = _stack
|
self.stack = _stack
|
||||||
self.batch = _batch
|
self.batch = _batch
|
||||||
|
self.index = 0
|
||||||
|
|
||||||
def on_report(self, status: dict) -> bool:
|
def on_report(self, status: dict) -> bool:
|
||||||
# Show reconstruction
|
do_continue = True
|
||||||
|
# print status values
|
||||||
|
Status.print_status(status)
|
||||||
# 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,)
|
||||||
|
|
||||||
for n in range(self.batch.shape[0]):
|
# User input
|
||||||
img = self.stack.pass_down_up(self.batch[n,:])
|
max_index = self.batch.shape[0]
|
||||||
cv_show("img", img, shape)
|
key = cv.waitKeyEx(1)
|
||||||
cv.waitKeyEx(1)
|
if key == ord('q'):
|
||||||
|
do_continue = False
|
||||||
|
if key == ord('-'):
|
||||||
|
self.index = max(0, self.index-1)
|
||||||
|
if key == ord('+'):
|
||||||
|
self.index = min(max_index, self.index+1)
|
||||||
|
|
||||||
Status.print_status(status)
|
# Show reconstruction
|
||||||
return True
|
img = self.stack.pass_down_up(self.batch[self.index,:])
|
||||||
|
cv_show("img", img, shape)
|
||||||
|
|
||||||
|
return do_continue
|
||||||
|
|
||||||
def read_armadillo(filename: str) -> np.ndarray:
|
def read_armadillo(filename: str) -> np.ndarray:
|
||||||
result = None
|
result = None
|
||||||
@@ -76,7 +87,7 @@ def main(prj_name: str = "test"):
|
|||||||
stack.state_save()
|
stack.state_save()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main("prims")
|
main("norb_small_16h")
|
||||||
cv.destroyAllWindows()
|
cv.destroyAllWindows()
|
||||||
|
|
||||||
print("Test: [passed]")
|
print("Test: [passed]")
|
||||||
|
|||||||
+3
-2
@@ -15,6 +15,7 @@ class Status:
|
|||||||
print(f"{key} : {value}{unit}")
|
print(f"{key} : {value}{unit}")
|
||||||
|
|
||||||
def on_change(self, status: dict) -> bool:
|
def on_change(self, status: dict) -> bool:
|
||||||
|
do_continue = True
|
||||||
if status == {}:
|
if status == {}:
|
||||||
self.progress = -1
|
self.progress = -1
|
||||||
|
|
||||||
@@ -22,9 +23,9 @@ class Status:
|
|||||||
progress = status["progress"]['value']
|
progress = status["progress"]['value']
|
||||||
if self.progress < 0 or progress - self.progress >= self.update_interval:
|
if self.progress < 0 or progress - self.progress >= self.update_interval:
|
||||||
self.progress = progress
|
self.progress = progress
|
||||||
self.on_report(status=status)
|
do_continue = self.on_report(status=status)
|
||||||
|
|
||||||
return True
|
return do_continue
|
||||||
|
|
||||||
def on_report(self, status: dict) -> bool:
|
def on_report(self, status: dict) -> bool:
|
||||||
return True
|
return True
|
||||||
Reference in New Issue
Block a user