<commit_before>#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os.path as osp

import chainer.optimizers as O
import chainer.serializers as S

import apc2015
import fcn
from fcn.models import FCN32s
from fcn.models import VGG16


def get_vgg16_pretrained_model(n_class):
    vgg16_path = fcn.setup.download_vgg16_chainermodel()
    vgg16 = VGG16()
    print('Loading vgg16 model: {0}'.format(vgg16_path))
    S.load_hdf5(vgg16_path, vgg16)
    return vgg16


def main():
    gpu = 0

    this_dir = osp.dirname(osp.abspath(__file__))
    db_path = osp.join(this_dir, 'leveldb')

    dataset = apc2015.APC2015(db_path=db_path)
    n_class = len(dataset.target_names)

    # setup model
    pretrained_model = get_vgg16_pretrained_model(n_class)
    model = FCN32s(n_class=n_class)
    fcn.util.copy_chainermodel(pretrained_model, model)
    if gpu != -1:
        model.to_gpu(gpu)

    # setup optimizer
    optimizer = O.MomentumSGD(lr=1e-25, momentum=0.99)
    optimizer.setup(model)

    # train
    trainer = fcn.Trainer(
        dataset=dataset,<commit_msg>Tuned the learning rate<commit_after>#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os.path as osp

import chainer.optimizers as O
import chainer.serializers as S

import apc2015
import fcn
from fcn.models import FCN32s
from fcn.models import VGG16


def get_vgg16_pretrained_model(n_class):
    vgg16_path = fcn.setup.download_vgg16_chainermodel()
    vgg16 = VGG16()
    print('Loading vgg16 model: {0}'.format(vgg16_path))
    S.load_hdf5(vgg16_path, vgg16)
    return vgg16


def main():
    gpu = 0

    this_dir = osp.dirname(osp.abspath(__file__))
    db_path = osp.join(this_dir, 'leveldb')

    dataset = apc2015.APC2015(db_path=db_path)
    n_class = len(dataset.target_names)

    # setup model
    pretrained_model = get_vgg16_pretrained_model(n_class)
    model = FCN32s(n_class=n_class)
    fcn.util.copy_chainermodel(pretrained_model, model)
    if gpu != -1:
        model.to_gpu(gpu)

    # setup optimizer
    optimizer = O.MomentumSGD(lr=1e-7, momentum=0.99)
    optimizer.setup(model)

    # train
    trainer = fcn.Trainer(
        dataset=dataset,
{'fraction_non_alphanumeric': 0.0898488120950324, 'fraction_numerical': 0.042764578833693306, 'mean_word_length': 3.865546218487395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4118552', 'n_tokens_mistral': 933, 'n_tokens_neox': 860, 'n_words': 176}