コード例 #1
0
ファイル: main.py プロジェクト: VLADORT/bachelor-diploma
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--tolabel",
        help="Preprocess images to create labels (out/tolabel)",
        action="store_true",
        default=False)
    parser.add_argument("--augmentation",
                        help="Dataset augmentation (pass quantity)",
                        type=int)
    parser.add_argument("--dataset",
                        help="Dataset name",
                        type=str,
                        default=constant.DATASET)
    parser.add_argument("--train",
                        help="Train",
                        action="store_true",
                        default=False)
    parser.add_argument("--test",
                        help="Predict",
                        action="store_true",
                        default=False)
    parser.add_argument("--arch",
                        help="Neural Network architecture",
                        type=str,
                        default=constant.MODEL)
    parser.add_argument("--dip",
                        help="Method for image processing",
                        type=str,
                        default=constant.IMG_PROCESSING)
    parser.add_argument("--gpu",
                        help="Enable GPU mode",
                        action="store_true",
                        default=False)
    args = parser.parse_args()

    environment.setup(args)
    exist = lambda x: len(x) > 0 and path.exist(path.data(x, mkdir=False))

    if (args.tolabel):
        generator.tolabel()

    elif args.dataset is not None and exist(args.dataset):

        if (args.augmentation):
            generator.augmentation(args.augmentation)

        elif (args.train):
            nn.train()

        elif (args.test):
            nn.test()
    else:
        print("\n>> Dataset not found\n")
コード例 #2
0
def main():
    dataset = "crackconcrete"
    train = True
    test = False
    environment.setup()
    exist = lambda x: len(x) > 0 and path.exist(path.data(x, mkdir=False))

    if dataset is not None and exist(dataset):
        if train:
            nn.train()
        elif test:
            nn.test()
    else:
        print("\n>> Dataset not found\n")
コード例 #3
0
#!/usr/bin/env/python
# coding: utf-8
from nn import nn
from random import seed

seed(1)
dataset = [[2.7810836, 2.550537003, 0], [1.465489372, 2.362125076, 0],
           [3.396561688, 4.400293529, 0], [1.38807019, 1.850220317, 0],
           [3.06407232, 3.005305973, 0], [7.627531214, 2.759262235, 1],
           [5.332441248, 2.088626775, 1], [6.922596716, 1.77106367, 1],
           [8.675418651, -0.242068655, 1], [7.673756466, 3.508563011, 1]]
n_inputs = len(dataset[0]) - 1
n_outputs = len(set([row[-1] for row in dataset]))
nn = nn.NN(n_inputs, 2, n_outputs)
nn.train(dataset, 0.5, 20)
network = nn.get_network()
for layer in network:
    print('{}\n'.format(layer))