def run_one_model(model, x_train, x_test, epc, name="model"): name += adding cprint(name, "green") start_time = time() sc_epc = show(model, x_train, x_test, y_train, y_test, plt=True, eps=epc, plt_title=name) scores[name] = [sc_epc, (time() - start_time)] clear_session()
#coding=utf-8 ''' hooktest ''' import func def _hook_show(*args, **kwargs): print "hook show func" realfun, = args return apply(realfun) def hook(): _show = func.show func.show = lambda: apply(_hook_show, (_show, )) #hook if __name__ == "__main__": hook() func.show()
def hook(): _show = func.show() # print("_show: ",_show) func.show = lambda: secu.apply(_hook_show, (_show, ))
[0, 7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 4], [0, 0, 8, 0, 0, 5, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 1, 0, 7, 5, 0], [0, 0, 0, 0, 7, 0, 0, 4, 2]]) #условие, с которым алгоритм справится за один заход board2 = np.array([[4, 2, 6, 8, 1, 9, 5, 7, 3], [9, 8, 3, 5, 7, 4, 2, 1, 6], [5, 1, 7, 2, 3, 6, 4, 8, 9], [1, 5, 8, 3, 4, 2, 9, 6, 7], [7, 4, 2, 9, 6, 8, 1, 3, 5], [3, 6, 9, 7, 5, 1, 8, 4, 2], [2, 7, 4, 6, 8, 5, 3, 9, 1], [8, 3, 5, 1, 9, 7, 6, 2, 4], [6, 9, 1, 4, 2, 3, 7, 5, 0]]) #невозможное условие, алгоритм должен сразу понять board3 = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 0], [0, 0, 0, 0, 0, 0, 0, 0, 9], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) #нулевая доска board0 = np.zeros((9, 9), int) #второе условия с диска, неоднозначное board5 = np.array([[8, 1, 0, 0, 3, 0, 0, 2, 7], [0, 6, 2, 0, 0, 0, 0, 9, 0], [0, 7, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 4], [0, 0, 8, 0, 0, 5, 0, 7, 0], [0, 0, 0, 0, 0, 0, 0, 8, 0], [0, 0, 0, 0, 1, 0, 7, 5, 0], [0, 0, 0, 0, 7, 0, 0, 4, 2]]) massive = [board, board5, board1, board2, board3, board0] #simple_solve(create_q(board5)) for i in range(200): q = hard_solve(create_q(massive[np.random.randint(len(massive))])) show(make_board(q))