示例#1
0
def get_model(state_num, action_num):
    model = NeuralRegressor(state_num)
    model.stack(
        Dense(HIDDEN_UNITS,
              activation='tanh',
              init=GaussianInitializer(deviation=0.01)),
        Dense(action_num, init=GaussianInitializer(deviation=0.01)))
    return model
示例#2
0
valid_set = data[:valid_size]

dataset = SequentialDataset(train_set, valid=valid_set)
dataset.report()

batch_set = MiniBatches(dataset, batch_size=32)

if __name__ == '__main__':

    ap = ArgumentParser()
    ap.add_argument("--model", default=os.path.join(os.path.dirname(__file__), "models", "sequence_adding_100_2.gz"))
    args = ap.parse_args()

    model = NeuralRegressor(input_dim=2, input_tensor=3)
    model.stack(IRNN(hidden_size=100, input_type="sequence",
                     output_type="one"),
                      Dense(1))

    if os.path.exists(args.model):
        model.load_params(args.model)

    conf = TrainerConfig()
    conf.learning_rate = LearningRateAnnealer.learning_rate(0.01)
    conf.gradient_clipping = 3
    conf.patience = 50
    conf.gradient_tolerance = 5
    conf.avoid_nan = False
    trainer = SGDTrainer(model, conf)

    annealer = LearningRateAnnealer(patience=20)
示例#3
0
文件: agent.py 项目: JunjieHu/deepy
def get_model(state_num, action_num):
    model = NeuralRegressor(state_num)
    model.stack(Dense(HIDDEN_UNITS, activation='tanh', init=GaussianInitializer(deviation=0.01)),
                Dense(action_num, init=GaussianInitializer(deviation=0.01)))
    return model