Пример #1
0
def train():
    model = lstm_model(config.seq_len, config.cell_num)

    # callback
    early_stopping = EarlyStopping(monitor='val_loss', patience=3)
    model_checkpoint = ModelCheckpoint(config.ckpt_path, save_best_only=True, save_weights_only=True)
    metrics = Metrics()

    dataset = Datasets.Dataset()

    hist = model.fit(dataset.train_data,
                     dataset.train_label,
                     batch_size=config.batch_size,
                     epochs=config.epoch_size,
                     shuffle=True,
                     validation_split=config.val_split,
                     callbacks=[early_stopping, model_checkpoint, metrics])

    with open(config.log_path, 'w') as f:
        f.write(str(hist.history) + '\n')
        f.write(str(metrics.val_f1s) + '\n')
        f.write(str(metrics.val_precisions) + '\n')
        f.write(str(metrics.val_recalls) + '\n')

    score, acc = model.evaluate(dataset.test_data,
                                dataset.test_label,
                                batch_size=config.batch_size)
    print(score, acc)
Пример #2
0
 def __init__(self):
     # datasets
     self.dataset = Datasets.Dataset(
         '/datasets/UCF101/jpegs_256',
         '/datasets/UCF101/UCF_list',
         '04',
         'spatial_dmd',
         30,
         24,
     )
     self.train_loader = self.dataset.get_loader('train')
     self.test_loader = self.dataset.get_loader('test')
     # networks
     self.net = Networks.Network(in_channels=13,
                                 out_classes=10,
                                 pretrain_path='./zoo/spatial_pretrain.pth')
Пример #3
0
# -*- coding: utf-8 -*-
"""
Created on Fri May  1 12:06:50 2015

@author: daniel
"""

import Datasets as ds

rawdata = ds.Dataset(
    "/home/daniel/data/datasets/UnderstandingSociety/tab/a_indresp.tab")