提交 aec1c2f0 编写于 作者: D dangqingqing

fix code style and copyright

上级 2f38be30
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
# Copyright (c) 2016 PaddlePaddle Authors. 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.
......
# Copyright (c) 2016 PaddlePaddle Authors. 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.
import os
import numpy as np
import cPickle
......@@ -7,22 +21,24 @@ CHANNEL = 3
HEIGHT = 32
WIDTH = 32
def create_mean(dataset):
if not os.path.isfile("mean.meta"):
mean = np.zeros(CHANNEL * HEIGHT * WIDTH)
num = 0
for f in dataset:
batch = np.load(f)
mean += batch['data'].sum(0)
mean += batch['data'].sum(0)
num += len(batch['data'])
mean /= num
print mean.size
data = {"mean": mean, "size": mean.size}
cPickle.dump(data, open("mean.meta", 'w'), protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.dump(
data, open("mean.meta", 'w'), protocol=cPickle.HIGHEST_PROTOCOL)
def create_data():
train_set = [DATA + "/data_batch_%d" % (i + 1) for i in xrange(0,5)]
train_set = [DATA + "/data_batch_%d" % (i + 1) for i in xrange(0, 5)]
test_set = [DATA + "/test_batch"]
# create mean values
......@@ -39,5 +55,6 @@ def create_data():
open("test.txt", "w").write("\n".join(test))
open("test.list", "w").write("\n".join(["data/test.txt"]))
if __name__ == '__main__':
create_data()
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
# Copyright (c) 2016 PaddlePaddle Authors. 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.
......@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
wget https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
tar zxf cifar-10-python.tar.gz
rm cifar-10-python.tar.gz
......
......@@ -14,8 +14,8 @@
# limitations under the License.
set -e
config=models/resnet.py
#config=models/vgg.py
#config=models/resnet.py
config=models/vgg.py
output=output
log=train.log
......@@ -26,4 +26,4 @@ paddle train \
--log_period=100 \
--num_passes=300 \
--save_dir=$output
#2>&1 | tee $log
2>&1 | tee $log
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册