import os
import time

import numpy as np
import tensorflow as tf

# from models import model
# import utils
from utils import CUR_TIME, logger, FLAGS

#########################################
# FLAGS
#########################################
# environmental parameters
FLAGS.add('--model',
          type=str,
          default='resnet',
          help='the type of NN model. cnn, crnn, resnn, resrnn...')
FLAGS.add('--outputs_dir',
          type=str,
          default='outputs/',
          help='Directory where to write event logs and checkpoint.')
FLAGS.add("--log_level",
          type=int,
          default=20,
          help="numeric value of logger level, 20 for info, 10 for debug.")
# FLAGS.add('--if_eval',
#           type=bool,
#           default=True,
#           help="Whether to log device placement.")
FLAGS.add('--debug',
          type=bool,
import tensorflow as tf
# from tensorflow.models.image.cifar10 import cifar10
# from tensorflow.models.image.cifar10 import cifar10_input
# from tensorflow.models.image.cifar10.cifar10_input import _generate_image_and_label_batch
from tensorflow.models.image.cifar10.cifar10_input import read_cifar10

# import utils
from utils import logger
from utils import FLAGS

#########################################
# FLAGS
#########################################
FLAGS.add('--data_dir',
          type=str,
          default='data/',
          help='directory for storing datasets and outputs.')
FLAGS.add('--num_read_threads',
          type=int,
          default=5,
          help='number of reading threads to shuffle examples '
          'between files.')
FLAGS.add("--max_images",
          type=int,
          help="save up to max_images number of images in summary.")

# dataset specific settings
FLAGS.add('--dataset',
          type=str,
          default='cifar-10',
          help='dataset type, each dataset has its own default settings.')
예제 #3
0
"""basic residual network class."""

import tensorflow as tf
from tensorflow.contrib.layers import variance_scaling_initializer
from tensorflow.contrib.layers import l2_regularizer
from tensorflow.contrib.layers import fully_connected

from models import basic_resnet
from models.basic_resnet import UnitsGroup
# from utils import logger
from utils import FLAGS

FLAGS.add('--groups_conf',
          type=str,
          default=''
          '3, 16, 64, 0\n'
          '3, 32, 128, 1\n'
          '16, 64, 256, 1',
          help='Configurations of different residual groups.')
FLAGS.add('--ror_l1',
          type=bool,
          default=True,
          help='RoR enable level 1 '
          'requirement: every group is downsampling')
FLAGS.add('--ror_l2',
          type=bool,
          default=True,
          help='RoR enable level 2, residual group shortcuts')


class Model(basic_resnet.Model):
예제 #4
0
# test logging
# ================================
# utils.set_logging(stream=False)
# utils.set_logger(stream=True)
# logger.info("logger111111")
logger.set_logger(stream=True)
logger.info(CUR_TIME)
logger.newline()
logger.error("newline beneath~")
logger.newline(2)
logger.info("haha")

# ================================
# test FLAGS
# ================================
FLAGS.add("--aa", type=float, default=11., help="doc for dd")
logger.info("aa: {}".format(FLAGS.get('aa')))
# for flag that should be overwrite later, don't set default
FLAGS.add("--bb", type=int, default=None, help="doc for dd")
if FLAGS.get('aa') == 11:
    FLAGS.overwrite_none(bb=15)

FLAGS.add("--cc", type=bool, default=False, help="doc for dd")
FLAGS.add("--dd", type=str, default="dddddd", help="doc for dd")
# for flag that should be overwrite later, don't set default
FLAGS.add("--ff", type=str, help="doc for dd")
FLAGS.add("--gg", type=str, help="doc for dd")
FLAGS.add("--hh", type=str, default="hhhhh", help="doc for dd")
# overwrite or set new default values
FLAGS.overwrite_defaults(dd="replaced dd", ee="an extra flag", ff="ff")
FLAGS.overwrite_none(hh="this won't show", gg="gggg", ii="illigal")
예제 #5
0
import tensorflow as tf
from tensorflow.contrib.layers import variance_scaling_initializer
from tensorflow.contrib.layers import l2_regularizer
from tensorflow.contrib.layers import fully_connected

from models import basic_resnet
# from models.basic_resnet import UnitsGroup
# from utils import logger
from utils import FLAGS

FLAGS.add(
    '--groups_conf',
    type=str,
    default=''
    '1, 16, 64, 0\n'
    # '2, 32, 64, 1\n'
    # '2, 64, 128, 1\n'
    '1, 16, 64, 0\n'
    '1, 32, 128, 0\n'
    '1, 64, 256, 0\n',
    help='Configurations of different residual groups.')
FLAGS.add('--max_pool',
          type=bool,
          default=True,
          help='whether to add max pooling before first residual unit.')
FLAGS.add('--resgroup_len',
          type=int,
          default=0,
          help='whether to add max pooling before first residual unit.')
FLAGS.add('--readout',
          type=int,
예제 #6
0
"""basic residual network class."""

import tensorflow as tf
from tensorflow.contrib.layers import variance_scaling_initializer
from tensorflow.contrib.layers import l2_regularizer
from tensorflow.contrib.layers import fully_connected

from models import basic_resnet
from models.basic_resnet import UnitsGroup
# from utils import logger
from utils import FLAGS

FLAGS.add('--groups_conf',
          type=str,
          default=''
          '3, 16, 32, 0\n'
          '4, 32, 64, 1\n'
          '6, 64, 128, 1\n'
          '3, 128, 256, 0',
          help='Configurations of different residual groups.')
FLAGS.add('--max_pool',
          type=bool,
          default=True,
          help='whether to add max pooling before first residual unit.')


class Model(basic_resnet.Model):
    """Residual neural network model.
    classify web page only based on target html."""
    def resnn(self, image_batch):
        """Build the resnn model.
        Args:
from collections import namedtuple

import tensorflow as tf
from tensorflow.contrib.layers import convolution2d
from tensorflow.contrib.layers import batch_norm
from tensorflow.contrib.layers import variance_scaling_initializer
from tensorflow.contrib.layers import l2_regularizer
from tensorflow.contrib.layers.python.layers import utils

from models import model
from utils import logger
from utils import FLAGS

FLAGS.add('--special_first',
          type=bool,
          default=False,
          help='special first residual unit from P14 of '
          '(arxiv.org/abs/1603.05027')
FLAGS.add('--shortcut',
          type=int,
          default=1,
          help='shortcut connection type: (arXiv:1512.03385)'
          '0: 0-padding and average pooling'
          '1: convolution projection only for increasing dimension'
          '2: projection for all shortcut')
FLAGS.add('--unit_type',
          type=int,
          default=0,
          help='# the type of residual unit '
          '# 0: post-activation; 1: pre-activation')
FLAGS.add('--residual_type',
예제 #8
0
import tensorflow as tf
from tensorflow.contrib.layers import variance_scaling_initializer
from tensorflow.contrib.layers import l2_regularizer
from tensorflow.contrib.layers import fully_connected

from models import basic_resnet
# from models.basic_resnet import UnitsGroup
# from utils import logger
from utils import FLAGS

FLAGS.overwrite_defaults(image_size=32)
FLAGS.add('--groups_conf',
          type=str,
          default=''
          '12, 12, -1, 1\n'
          '12, 12, -1, 1\n'
          '12, 12, -1, 0',
          help='Configurations of different residual groups.')


class Model(basic_resnet.Model):
    """Residual neural network model.
    classify web page only based on target html."""
    def resnn(self, image_batch):
        """Build the resnn model.
        Args:
            image_batch: Sequences returned from inputs_train() or inputs_eval.
        Returns:
            Logits.
        """