# Path: hamaa/utils/np_utils.py
# def to_one_hot(y, nb_class):
# def to_categorical(y):
# def split_training_data(data, nb_validation=None, split_ratio=None):
# def padding(images, pad_size):
# def rot180(images):
# def eval_numerical_gradient_array(f, x, df=None, verbose=False, h=1e-4):
# def sum_abs_err(u, v):
# 
# Path: hamaa/utils/time_utils.py
# class ProgressBar:
#     """控制台进度条类"""
# 
#     def __init__(self, total=0, width=20):
#         """
#         :param total: 进度最大值，整数类型
#         :param width: 进图条显示宽度，单位为一个字符占位格
#         """
#         # 当前轮数，类型为整数值
#         self.current = 0
#         self.total = total
#         self.width = width
#         self.timestamp = None
#         self.one_move_time = 0
# 
#     def move(self, step=1):
#         self.current += step
#         if self.timestamp:
#             self.one_move_time = (time.time() - self.timestamp) / step
#         self.timestamp = time.time()
# 
#     def clear(self):
#         """清空进度条"""
#         sys.stdout.write('\r')
#         sys.stdout.write(' ' * (100))
#         sys.stdout.write('\r')
#         sys.stdout.flush()
# 
#     def reset(self):
#         """重置进度条进度"""
#         self.current = 0
# 
#     def show(self, head='', message=''):
#         self.clear()
#         # 计算当前进度百分比
#         percent = self.current * 1.0 / self.total
#         # 根据百分比以及进度条总长度，计算当前进度的占位符宽度
#         progress = int(math.ceil(self.width * percent))
#         if progress == self.width:
#             progress -= 1
#         # 估计剩余耗时
#         remaining_time = (self.total - self.current) * self.one_move_time
#         # 打印进度条头
#         sys.stdout.write(head + ',  {0:3}/{1}: '.format(self.current, self.total))
#         # 打印进度条
#         sys.stdout.write('[' + '='*progress + '>' + ' '*(self.width - progress - 1) + '] remaining time: %.2fs' % remaining_time)
#         # 打印尾随信息
#         sys.stdout.write(message)
#         sys.stdout.flush()
# 
#         # 如果进度完成，则输出换行符（永久打印在控制台上）
#         # if self.current == self.total:
#         #     sys.stdout.write('\n')
#         #     sys.stdout.flush()


import sys
import time
import warnings
import matplotlib.pyplot as plt
import numpy as np
from .utils import np_utils
from .utils.time_utils import ProgressBar
        plt.scatter(epoch, training_acc, marker='*')
        if validation_acc:
            plt.plot(epoch, validation_acc, label='validation')
            plt.scatter(epoch, validation_acc, marker='*')
        plt.legend(loc=0)

        # 绘画损失函数值随着训练周期的折线图
        plt.subplot(313)
        if validation_acc:
            top = max(np.max(training_loss), np.max(validation_loss))
        else:
            top = np.max(training_loss)
        plt.xlim([1, epoch[-1]])
        plt.ylim([0, 0.1 + top])
        plt.xlabel('epoch')
        plt.ylabel('loss')
        plt.plot(epoch, training_loss, label='training')
        plt.scatter(epoch, training_loss, marker='*')
        if validation_loss:
            plt.plot(epoch, validation_loss, label='validation')
            plt.scatter(epoch, validation_loss, marker='*')
        plt.legend(loc=0)

        plt.show()

    def plot_prediction(self, model, data):
        """绘画出决策边界。只适用于数据维数为2的情况。"""
        x, y = data
        # 如果y是one-hot，则重置为categorical
        if np.shape(y)[1] != 1:

# Path: hamaa/utils/np_utils.py
# def to_one_hot(y, nb_class):
# def to_categorical(y):
# def split_training_data(data, nb_validation=None, split_ratio=None):
# def padding(images, pad_size):
# def rot180(images):
# def eval_numerical_gradient_array(f, x, df=None, verbose=False, h=1e-4):
# def sum_abs_err(u, v):
# 
# Path: hamaa/utils/time_utils.py
# class ProgressBar:
#     """控制台进度条类"""
# 
#     def __init__(self, total=0, width=20):
#         """
#         :param total: 进度最大值，整数类型
#         :param width: 进图条显示宽度，单位为一个字符占位格
#         """
#         # 当前轮数，类型为整数值
#         self.current = 0
#         self.total = total
#         self.width = width
#         self.timestamp = None
#         self.one_move_time = 0
# 
#     def move(self, step=1):
#         self.current += step
#         if self.timestamp:
#             self.one_move_time = (time.time() - self.timestamp) / step
#         self.timestamp = time.time()
# 
#     def clear(self):
#         """清空进度条"""
#         sys.stdout.write('\r')
#         sys.stdout.write(' ' * (100))
#         sys.stdout.write('\r')
#         sys.stdout.flush()
# 
#     def reset(self):
#         """重置进度条进度"""
#         self.current = 0
# 
#     def show(self, head='', message=''):
#         self.clear()
#         # 计算当前进度百分比
#         percent = self.current * 1.0 / self.total
#         # 根据百分比以及进度条总长度，计算当前进度的占位符宽度
#         progress = int(math.ceil(self.width * percent))
#         if progress == self.width:
#             progress -= 1
#         # 估计剩余耗时
#         remaining_time = (self.total - self.current) * self.one_move_time
#         # 打印进度条头
#         sys.stdout.write(head + ',  {0:3}/{1}: '.format(self.current, self.total))
#         # 打印进度条
#         sys.stdout.write('[' + '='*progress + '>' + ' '*(self.width - progress - 1) + '] remaining time: %.2fs' % remaining_time)
#         # 打印尾随信息
#         sys.stdout.write(message)
#         sys.stdout.flush()
# 
#         # 如果进度完成，则输出换行符（永久打印在控制台上）
#         # if self.current == self.total:
#         #     sys.stdout.write('\n')
#         #     sys.stdout.flush()


# Path: hamaa/trainers.py
import sys
import time
import warnings
import matplotlib.pyplot as plt
import numpy as np
from .utils import np_utils
from .utils.time_utils import ProgressBar

        plt.scatter(epoch, training_acc, marker='*')
        if validation_acc:
            plt.plot(epoch, validation_acc, label='validation')
            plt.scatter(epoch, validation_acc, marker='*')
        plt.legend(loc=0)

        # 绘画损失函数值随着训练周期的折线图
        plt.subplot(313)
        if validation_acc:
            top = max(np.max(training_loss), np.max(validation_loss))
        else:
            top = np.max(training_loss)
        plt.xlim([1, epoch[-1]])
        plt.ylim([0, 0.1 + top])
        plt.xlabel('epoch')
        plt.ylabel('loss')
        plt.plot(epoch, training_loss, label='training')
        plt.scatter(epoch, training_loss, marker='*')
        if validation_loss:
            plt.plot(epoch, validation_loss, label='validation')
            plt.scatter(epoch, validation_loss, marker='*')
        plt.legend(loc=0)

        plt.show()

    def plot_prediction(self, model, data):
        """绘画出决策边界。只适用于数据维数为2的情况。"""
        x, y = data
        # 如果y是one-hot，则重置为categorical
        if np.shape(y)[1] != 1:

            y = np_utils.to_categorical(y)