예제 #1
0
 def __init__(self,
              data=nn.Dataset(tensor.Tensor([1], [1]),
                              tensor.Tensor([1], [1])),
              network=nn.Network(),
              optimizer=nn.optimizer.SGD(0.01)):
     self.data = data
     self.network = network
     self.optimizer = optimizer
예제 #2
0
파일: ex2_xor2.py 프로젝트: pirate1111/test
import NN as nn
import tensor
import time

print('start')
# 다른 프로세스가 중복 실행을 방지
if __name__ == '__main__':
    # xor 데이터
    x = tensor.Tensor(
        [0., 0., 0., 1., 1., 0., 1., 1., 0., 0., 0., 1., 1., 0., 1., 1.],
        [8, 2])
    y = tensor.Tensor(
        [0., 1., 1., 0., 1., 0., 0., 1., 0., 1., 1., 0., 1., 0., 0., 1.],
        [8, 2])
    data = nn.Dataset(x, y)

    # 입력층 뉴련이 2개인 네트워크 생성
    network = nn.Network(2)

    # 뉴런이 4개인 히든층
    network.append_affine(
        4).append_batchnormalization().append_shift().append_sigmoid()
    # 뉴런이 2개인 출력층
    network.append_affine(2).append_softmax()

    # 옵티마이저
    optimizer = nn.optimizer.SGD(0.01)

    # 학습을 위한 객체 생성
    learner = nn.Learner(data, network, optimizer)
예제 #3
0
from __future__ import absolute_import, division, print_function, unicode_literals

import utils
import preprocessing as pre
import numpy as np
import time
import os
import numpy as np
import matplotlib.pyplot as plt
import random
import NN as nn

train_data_dir, train_labels_path = "data/gtsrb-german-traffic-sign/Train", "./data/gtsrb-german-traffic-sign/Train.csv"
train_data_set = nn.Dataset(train_data_dir,
                            train_labels_path,
                            data='train',
                            n_samples=2000)

test_data_dir, test_labels_path = "data/gtsrb-german-traffic-sign/Test", "./data/gtsrb-german-traffic-sign/Test.csv"
test_data_set = nn.Dataset(test_data_dir, test_labels_path, data='test')

reshaped_train_images = []
for image in train_data_set.X:
    dst = pre.eqHist(image)
    dst = pre.reshape(dst)
    reshaped_train_images.append(dst)
train_data_set.X = reshaped_train_images

reshaped_test_images = []
for image in test_data_set.X:
    dst = pre.eqHist(image)