Skip to content
Snippets Groups Projects
Unverified Commit e7cba8b2 authored by i-robot's avatar i-robot Committed by Gitee
Browse files

!2719 remove modelzoo some warnings

Merge pull request !2719 from anzhengqi/remove-warnings-network
parents 487c0800 eb40ecc2
No related branches found
No related tags found
No related merge requests found
......@@ -121,14 +121,14 @@ def default_recurisive_init(custom_cell):
for _, cell in custom_cell.cells_and_names():
if isinstance(cell, nn.Conv2d):
cell.weight.set_data(init.initializer(KaimingUniform(a=math.sqrt(5.0)), cell.weight.data.shape,
cell.weight.data.dtype).to_tensor())
cell.weight.data.dtype).init_data())
if cell.bias is not None:
fan_in, _ = _calculate_in_and_out(cell.weight.data.asnumpy())
bound = 1 / math.sqrt(fan_in)
cell.bias.set_data(Tensor(np.random.uniform(-bound, bound, cell.bias.data.shape), cell.bias.data.dtype))
elif isinstance(cell, nn.Dense):
cell.weight.set_data(init.initializer(KaimingUniform(a=math.sqrt(5)), cell.weight.data.shape,
cell.weight.data.dtype).to_tensor())
cell.weight.data.dtype).init_data())
if cell.bias is not None:
fan_in, _ = _calculate_in_and_out(cell.weight.data.asnumpy())
bound = 1 / math.sqrt(fan_in)
......
......@@ -68,9 +68,6 @@ After dataset preparation, you can start training and evaluation as follows:
cd ./scripts
bash run_standalone_train.sh [TRAIN_DATASET] [DEVICEID] [DATANAME]
# run distributed training example
bash run_distribute_train.sh [TRAIN_DATASET] [RANK_TABLE_PATH] [DATANAME]
# run evaluation example
bash run_eval.sh [EVAL_DATASET_PATH] [DATASET_NAME] [MODEL_CKPT] [DEVICEID]
```
......@@ -220,13 +217,6 @@ Parameters for both training and evaluation can be set in config.py. All the dat
bash run_standalone_train.sh [DATASET_PATH] [DEVICE_ID] [DATANAME]
```
- Running scripts for distributed training of FastText. Task training on multiple device and run the following command in bash to be executed in `scripts/`:
```bash
cd ./scripts
bash run_distributed_train.sh [DATASET_PATH] [RANK_TABLE_PATH] [DATANAME]
```
- Running on GPU
- Start task training on a single device and run the shell script
......
#!/bin/bash
# Copyright 2020 Huawei Technologies Co., Ltd
#
# 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.
# ============================================================================
echo "=============================================================================================================="
echo "Please run the script as: "
echo "sh run_distributed_train.sh DATASET_PATH RANK_TABLE_PATH"
echo "for example: sh run_distributed_train.sh /home/workspace/ag /home/workspace/rank_table_file.json ag"
echo "It is better to use absolute path."
echo "Please pay attention that the dataset should corresponds to dataset_name"
echo "=============================================================================================================="
get_real_path(){
if [ "${1:0:1}" == "/" ]; then
echo "$1"
else
echo "$(realpath -m $PWD/$1)"
fi
}
if [ $3 != "ag" ] && [ $3 != "dbpedia" ] && [ $3 != "yelp_p" ]
then
echo "Unrecognized dataset name, the name can choose from [ag, dbpedia, yelp_p]"
exit 1
fi
DATASET=$(get_real_path $1)
echo $DATASET
RANK_TABLE_PATH=$(get_real_path $2)
if [ ! -d $DATASET ]
then
echo "Error: DATA_PATH=$DATASET is not a file"
exit 1
fi
current_exec_path=$(pwd)
echo ${current_exec_path}
export RANK_TABLE_FILE=$RANK_TABLE_PATH
echo $RANK_TABLE_FILE
export RANK_SIZE=8
export DEVICE_NUM=8
if [ $# -ge 1 ]; then
if [ $3 == 'ag' ]; then
DATANAME='ag'
elif [ $3 == 'dbpedia' ]; then
DATANAME='dbpedia'
elif [ $3 == 'yelp_p' ]; then
DATANAME='yelp_p'
else
echo "Unrecognized dataset name,he name can choose from [ag, dbpedia, yelp_p]"
exit 1
fi
fi
config_path="./${DATANAME}_config.yaml"
echo "config path is : ${config_path}"
for((i=0;i<=7;i++));
do
rm -rf ${current_exec_path}/device$i
mkdir ${current_exec_path}/device$i
cd ${current_exec_path}/device$i || exit
cp ../../*.py ./
cp ../../*.yaml ./
cp -r ../../src ./
cp -r ../../model_utils ./
cp -r ../*.sh ./
export RANK_ID=$i
export DEVICE_ID=$i
echo "start training for rank $i, device $DEVICE_ID"
python ../../train.py --config_path $config_path --dataset_path $DATASET --data_name $DATANAME > log_fasttext.log 2>&1 &
cd ${current_exec_path} || exit
done
cd ${current_exec_path} || exit
......@@ -113,7 +113,6 @@ def train_wide_and_deep():
enable_graph_kernel=_enable_graph_kernel, device_target=cfg.device_target)
if _enable_graph_kernel:
context.set_context(graph_kernel_flags="--enable_cluster_ops=MatMul")
context.set_context(enable_sparse=cfg.sparse)
test_train_eval(cfg)
if __name__ == "__main__":
......
......@@ -154,7 +154,6 @@ def train_wide_and_deep():
if cfg.device_target == "GPU":
context.set_context(enable_graph_kernel=True)
context.set_context(variable_memory_max_size="24GB")
context.set_context(enable_sparse=True)
init()
context.set_context(save_graphs_path='./graphs_of_device_id_' + str(get_rank()), save_graphs=True)
if cfg.sparse:
......
......@@ -130,7 +130,6 @@ def train_wide_and_deep():
context.set_context(enable_graph_kernel=True)
context.set_context(graph_kernel_flags="--enable_cluster_ops=MatMul")
context.set_context(enable_sparse=cfg.sparse)
init()
context.set_context(save_graphs_path='./graphs_of_device_id_'+str(get_rank()))
context.set_auto_parallel_context(parallel_mode=ParallelMode.DATA_PARALLEL, gradients_mean=True,
......
......@@ -167,8 +167,6 @@ def train_wide_and_deep():
device_num=get_group_size())
cfg.sparse = True
if cfg.sparse:
context.set_context(enable_sparse=True)
if cfg.device_target == "GPU":
context.set_context(enable_graph_kernel=True)
context.set_context(graph_kernel_flags="--enable_cluster_ops=MatMul")
......
......@@ -127,8 +127,6 @@ def train_wide_and_deep():
""" train_wide_and_deep """
if not cache_enable:
cfg.sparse = True
if cfg.sparse:
context.set_context(enable_sparse=True)
if cfg.device_target == "GPU":
context.set_context(enable_graph_kernel=True)
context.set_context(graph_kernel_flags="--enable_cluster_ops=MatMul")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment