You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
3.6 KiB
170 lines
3.6 KiB
#edit-mode: -*- python -*-
|
|
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
#Todo(luotao02) This config is only used for unitest. It is out of date now, and will be updated later.
|
|
|
|
default_initial_std(0.5)
|
|
|
|
model_type("nn")
|
|
|
|
DataLayer(
|
|
name = "input",
|
|
size = 3,
|
|
)
|
|
|
|
DataLayer(
|
|
name = "weight",
|
|
size = 1,
|
|
)
|
|
|
|
Layer(
|
|
name = "layer1_1",
|
|
type = "fc",
|
|
size = 5,
|
|
active_type = "sigmoid",
|
|
inputs = "input",
|
|
)
|
|
|
|
Layer(
|
|
name = "layer1_2",
|
|
type = "fc",
|
|
size = 12,
|
|
active_type = "linear",
|
|
inputs = Input("input", parameter_name='sharew'),
|
|
)
|
|
|
|
Layer(
|
|
name = "layer1_3",
|
|
type = "fc",
|
|
size = 3,
|
|
active_type = "tanh",
|
|
inputs = "input",
|
|
)
|
|
|
|
Layer(
|
|
name = "layer1_5",
|
|
type = "fc",
|
|
size = 3,
|
|
active_type = "tanh",
|
|
inputs = Input("input",
|
|
learning_rate=0.01,
|
|
momentum=0.9,
|
|
decay_rate=0.05,
|
|
initial_mean=0.0,
|
|
initial_std=0.01,
|
|
format = "csc",
|
|
nnz = 4)
|
|
)
|
|
|
|
FCLayer(
|
|
name = "layer1_4",
|
|
size = 5,
|
|
active_type = "square",
|
|
inputs = "input",
|
|
drop_rate = 0.5,
|
|
)
|
|
|
|
Layer(
|
|
name = "pool",
|
|
type = "pool",
|
|
inputs = Input("layer1_2",
|
|
pool = Pool(pool_type="cudnn-avg-pool",
|
|
channels = 1,
|
|
size_x = 2,
|
|
size_y = 3,
|
|
img_width = 3,
|
|
padding = 1,
|
|
padding_y = 2,
|
|
stride = 2,
|
|
stride_y = 3))
|
|
)
|
|
|
|
Layer(
|
|
name = "concat",
|
|
type = "concat",
|
|
inputs = ["layer1_3", "layer1_4"],
|
|
)
|
|
|
|
MixedLayer(
|
|
name = "output",
|
|
size = 3,
|
|
active_type = "softmax",
|
|
inputs = [
|
|
FullMatrixProjection("layer1_1",
|
|
learning_rate=0.1),
|
|
TransposedFullMatrixProjection("layer1_2", parameter_name='sharew'),
|
|
FullMatrixProjection("concat"),
|
|
IdentityProjection("layer1_3"),
|
|
],
|
|
)
|
|
|
|
Layer(
|
|
name = "label",
|
|
type = "data",
|
|
size = 1,
|
|
)
|
|
|
|
Layer(
|
|
name = "cost",
|
|
type = "multi-class-cross-entropy",
|
|
inputs = ["output", "label", "weight"],
|
|
)
|
|
|
|
Layer(
|
|
name = "cost2",
|
|
type = "nce",
|
|
num_classes = 3,
|
|
active_type = "sigmoid",
|
|
neg_sampling_dist = [0.1, 0.3, 0.6],
|
|
inputs = ["layer1_2", "label", "weight"],
|
|
)
|
|
|
|
Evaluator(
|
|
name = "error",
|
|
type = "classification_error",
|
|
inputs = ["output", "label", "weight"]
|
|
)
|
|
|
|
Inputs("input", "label", "weight")
|
|
Outputs("cost", "cost2")
|
|
|
|
TrainData(
|
|
ProtoData(
|
|
files = "dummy_list",
|
|
constant_slots = [1.0],
|
|
async_load_data = True,
|
|
)
|
|
)
|
|
|
|
TestData(
|
|
SimpleData(
|
|
files = "trainer/tests/sample_filelist.txt",
|
|
feat_dim = 3,
|
|
context_len = 0,
|
|
buffer_capacity = 1000000,
|
|
async_load_data = False,
|
|
),
|
|
)
|
|
|
|
Settings(
|
|
algorithm = "sgd",
|
|
num_batches_per_send_parameter = 1,
|
|
num_batches_per_get_parameter = 1,
|
|
batch_size = 100,
|
|
learning_rate = 0.001,
|
|
learning_rate_decay_a = 1e-5,
|
|
learning_rate_decay_b = 0.5,
|
|
)
|