Ejemplo n.º 1
0
##print('check channel order = ', model.is_contiguous(memory_format=torch.channels_last))
print('==== model info ====')
summary(model, (100, 100, 3))
print('====================')

## no Train Model Save
model.eval()
trace_input = torch.rand(1, 100, 100, 3).to(DEVICE, dtype=torch.float32)
traced_script_module = torch.jit.trace(model, trace_input)
traced_script_module.save(
    "C://Github//DeepLearningStudy//trained_model//NoTrainAnimalClassificationV1.pt"
)
## no Train Model Save

loader_train = dataloader(
    'C://Github//DeepLearningStudy//dataset//animal-train-v1')
loader_valid = dataloader(
    'C://Github//DeepLearningStudy//dataset//animal-validation-v1')

learning_rate = 0.001
batch_size = 10
sample_size = loader_train.sample_count()
total_batch = int(sample_size / batch_size)
target_accuracy = 0.86

valid_sample_size = loader_valid.sample_count()

optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
cost = torch.nn.CrossEntropyLoss()

for epoch in range(200):
import numpy as np
import tensorflow as tf
from model.LeafletLineClassification import LeafletLineClassification
from tensorflow.keras.models import model_from_json
from util.dataloader import dataloader

loader_train = dataloader(
    'C://Github//LeafletImageCropTool//Data//ClassificationExperiment')
loader_train.shuffle()

learning_rate = 0.001
batch_size = 80
sample_size = loader_train.sample_count()
total_batch = int(sample_size / batch_size)
target_accuracy = 0.9997

model = LeafletLineClassification(learning_rate=learning_rate)
tf.keras.utils.plot_model(
    model.get_model(),
    to_file=
    'C:\\Github\\DeepLearningStudy\\trained_model\\LeafletLineClassification.png',
    show_shapes=True,
    show_layer_names=True)

for epoch in range(200):
    average_cost = 0
    average_accuracy = 0
    for batch in range(total_batch):
        inputs_train, outputs_train = loader_train.load([100, 512, 3], 1,
                                                        batch_size, True)
        if inputs_train is None or outputs_train is None:
Ejemplo n.º 3
0
import numpy as np
import tensorflow as tf
from model.StampClassification import StampClassification
from tensorflow.keras.models import model_from_json
from util.dataloader import dataloader

loader_train = dataloader('C://Github//DoksanData//TRAIN_DIR')

learning_rate = 0.0009
batch_size = 500
sample_size = loader_train.sample_count()
total_batch = int(sample_size / batch_size)
target_accuracy = 0.9997

model = StampClassification(learning_rate=learning_rate)
tf.keras.utils.plot_model(
    model.get_model(),
    to_file=
    'C:\\Github\\DeepLearningStudy\\trained_model\\StampClassification.png',
    show_shapes=True,
    show_layer_names=True)

for epoch in range(200):
    average_cost = 0
    average_accuracy = 0
    for batch in range(total_batch):
        inputs_train, outputs_train = loader_train.load([35, 35, 3], 1.0,
                                                        batch_size, True)
        if inputs_train is None or outputs_train is None:
            break
import numpy as np
import tensorflow as tf
from model.SimpleConvRecogCharacter import SimpleConvRecogCharacter
from tensorflow.keras.models import model_from_json
from util.dataloader import dataloader

loader_train = dataloader(
    'C://Github//DeepLearningStudy//dataset//digits-train')

learning_rate = 0.001
batch_size = 50
sample_size = loader_train.sample_count()
total_batch = int(sample_size / batch_size)
target_accuracy = 0.99

model = SimpleConvRecogCharacter(learning_rate=learning_rate)

for epoch in range(200):
    average_cost = 0
    average_accuracy = 0
    for batch in range(total_batch):
        inputs_train, outputs_train = loader_train.load([28, 28, 1],
                                                        [1, 1, 10], 1.0,
                                                        batch_size, False)
        if inputs_train is None or outputs_train is None:
            break

        cost = model.train_one_batch(inputs_train, outputs_train)
        accuracy = model.accracy_on_batch(inputs_train, outputs_train)
        average_cost += (cost / total_batch)
        average_accuracy += (accuracy / total_batch)