コード例 #1
0
ファイル: evaluation.py プロジェクト: shlpu/CNN
def cpu_vs_gpu(epochs, train_data, validation_data, table_output_path = ''):
    """
    This function can be used ot produce to compare the speed (in seconds) between
    the usage of the gpu and cpu.
    :param epochs: A list of epochs which should be used
    :param train_data: The training data (obtained from splitter.py)
    :param validation_data: The validation data (obtained from splitter.py)
    :param table_output_path: The path to which the output should be written
    """
    gpu_results = []
    cpu_results = []
    p = Plotter()
    for epoch in epochs:
        gpu_params = edit_params(['hm_epochs' ,'gpu'], [epoch, True])
        cpu_params = edit_params(['hm_epochs' ,'gpu'], [epoch, False])
        gpu_results.append(CNN().run_model(gpu_params, train_data, validation_data))
        cpu_results.append(CNN().run_model(cpu_params, train_data, validation_data))

    gpu_x, gpu_y = p.get_x_y(gpu_results, 'number_epochs', 'run_time')
    cpu_x, cpu_y = p.get_x_y(cpu_results, 'number_epochs', 'run_time')
    if table_output_path:
        header = ['epoch','gpu_time','cpu_time']
        write_to_file(table_output_path + 'gpu_vs_cpu.txt',header, [gpu_x, gpu_y, cpu_y])
    p.double_line([gpu_x,cpu_x], [gpu_y, cpu_y], ['GPU','CPU'])
コード例 #2
0
__author__ = 'matthew'
from Mesh import Mesh
from Solver import Solver
from Plot import Plotter
import Glob

#Create mesh
mesh = Mesh()

#create solver and run loop
solver = Solver(mesh=mesh)
solver.solverLoop(mesh)

#Create plotter and plot
plotter = Plotter(mesh)
plotter.plot()