Beispiel #1
0
NUM_LAYERS = 4  # number of layers of the state space
MAX_TRIALS = 100  # maximum number of models generated
MAX_EPOCHS = 8  # maximum number of epochs to train
CHILD_BATCHSIZE = 128  # batchsize of the child models
EXPLORATION = 0.9  # high exploration for the first 1000 steps
REGULARIZATION = 1e-3  # regularization strength
CONTROLLER_CELLS = 64  # number of cells in RNN controller
EMBEDDING_DIM = 20  # dimension of the embeddings for each state
ACCURACY_BETA = 0.85  # beta value for the moving average of the accuracy
CLIP_REWARDS = 0.0  # clip rewards in the [-0.05, 0.05] range

# construct a state space
state_space = StateSpace()
# add states
state_space.add_state(name='neurons', values=range(32, 512, 32))
state_space.print_state_space()


def train(dataset1, dataset2, initial_state, if_restore):
    total_reward = 0.0
    with policy_sess.as_default():
        # create the Controller and build the internal policy network
        controller = Controller(policy_sess,
                                NUM_LAYERS,
                                state_space,
                                reg_param=REGULARIZATION,
                                exploration=EXPLORATION,
                                controller_cells=CONTROLLER_CELLS,
                                embedding_dim=EMBEDDING_DIM,
                                restore_controller=if_restore)
Beispiel #2
0
CHILD_BATCHSIZE = 128  # batchsize of the child models
EXPLORATION = 0.8  # high exploration for the first 1000 steps
REGULARIZATION = 1e-3  # regularization strength
CONTROLLER_CELLS = 32  # number of cells in RNN controller
EMBEDDING_DIM = 20  # dimension of the embeddings for each state
ACCURACY_BETA = 0.8  # beta value for the moving average of the accuracy
CLIP_REWARDS = 0.0  # clip rewards in the [-0.05, 0.05] range
RESTORE_CONTROLLER = True  #

# construct a state space
state_space = StateSpace()

# add states
#state_space.add_state(name='kernel', values=[1,3])
#state_space.add_state(name='filters', values=[16, 32, 64])
state_space.add_state(name='partial_frac', values=[0.9, 0.75, 0.5])
state_space.add_state(name='input_size', values=[60, 100, 150, 224])
state_space.add_state(name='CNN_one', values=[2, 3, 4, 5])
state_space.add_state(name='CNN_two', values=[2, 3, 4, 5])
state_space.add_state(name='CNN_three', values=[2, 3, 4, 5])
state_space.print_state_space()
'''
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train = x_train.astype('float32') / 255.
x_test = x_test.astype('float32') / 255.
y_train = to_categorical(y_train, 10)
y_test = to_categorical(y_test, 10)

dataset = [x_train, y_train, x_test, y_test]
'''