提交 a0844274 编写于 作者: 李寅

Merge branch 'file_name_bug' into 'master'

Fix input/output file name not consistent between python and c++.

See merge request !538
...@@ -44,5 +44,7 @@ class CaffeEnvType(enum.Enum): ...@@ -44,5 +44,7 @@ class CaffeEnvType(enum.Enum):
# common functions # common functions
################################ ################################
def formatted_file_name(input_file_name, input_name): def formatted_file_name(input_file_name, input_name):
return input_file_name + '_' + \ res = input_file_name + '_'
re.sub('[^0-9a-zA-Z]+', '_', input_name) for c in input_name:
res += c if c.isalnum() else '_'
return res
...@@ -16,6 +16,7 @@ import argparse ...@@ -16,6 +16,7 @@ import argparse
import sys import sys
import numpy as np import numpy as np
import re import re
import common
# Validation Flow: # Validation Flow:
# 1. Generate input data # 1. Generate input data
...@@ -29,8 +30,7 @@ import re ...@@ -29,8 +30,7 @@ import re
def generate_data(name, shape, input_file): def generate_data(name, shape, input_file):
np.random.seed() np.random.seed()
data = np.random.random(shape) * 2 - 1 data = np.random.random(shape) * 2 - 1
input_file_name = input_file + "_" + re.sub('[^0-9a-zA-Z]+', '_', input_file_name = common.formatted_file_name(input_file, name)
name)
print 'Generate input file: ', input_file_name print 'Generate input file: ', input_file_name
data.astype(np.float32).tofile(input_file_name) data.astype(np.float32).tofile(input_file_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册