Skip to content

Commit e6b7d42

Browse files
committed
add dygraph to static
1 parent 82eed5f commit e6b7d42

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

models/rank/dnn/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runner:
2222
use_gpu: False
2323
use_auc: True
2424
train_batch_size: 2
25-
epochs: 3
25+
epochs: 1
2626
print_interval: 2
2727
model_save_path: "output_model_dnn"
2828
infer_batch_size: 2
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# workspace
16+
#workspace: "models/rank/dnn"
17+
18+
19+
runner:
20+
train_data_dir: "data/sample_data/train"
21+
train_reader_path: "criteo_reader" # importlib format
22+
model_init_path: "output_model_dnn/0" # model_init
23+
use_gpu: False
24+
use_auc: True
25+
train_batch_size: 2
26+
epochs: 1
27+
print_interval: 2
28+
model_save_path: "output_model_dnn2" # save path
29+
infer_batch_size: 2
30+
infer_reader_path: "criteo_reader" # importlib format
31+
test_data_dir: "data/sample_data/train"
32+
infer_load_path: "output_model_dnn"
33+
infer_start_epoch: 0
34+
infer_end_epoch: 3
35+
36+
# distribute_config
37+
sync_mode: "async"
38+
split_file_list: False
39+
thread_num: 1
40+
41+
42+
# hyper parameters of user-defined network
43+
hyper_parameters:
44+
# optimizer config
45+
optimizer:
46+
class: Adam
47+
learning_rate: 0.001
48+
strategy: async
49+
# user-defined <key, value> pairs
50+
sparse_inputs_slots: 27
51+
sparse_feature_number: 1000001
52+
sparse_feature_dim: 9
53+
dense_input_dim: 13
54+
fc_sizes: [512, 256, 128, 32]
55+
distributed_embedding: 0

tools/utils/save_load.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ def save_model(net, optimizer, model_path, epoch_id, prefix='rec'):
3030
logger.info("Already save model in {}".format(model_path))
3131

3232

33+
def save_jit_model(net, model_path, prefix='tostatic'):
34+
_mkdir_if_not_exist(model_path)
35+
model_prefix = os.path.join(model_path, prefix)
36+
#paddle.save(net.state_dict(), model_prefix + ".pdparams")
37+
paddle.jit.save(net, model_prefix)
38+
logger.info("Already save jit model in {}".format(model_path))
39+
40+
3341
def load_model(model_path, net, prefix='rec'):
3442
logger.info("start load model from {}".format(model_path))
3543
model_prefix = os.path.join(model_path, prefix)

0 commit comments

Comments
 (0)