Commit 19069210 authored by Yuxin Wu's avatar Yuxin Wu

bug fix

parent a3de7ec7
...@@ -124,7 +124,7 @@ def run_test(path): ...@@ -124,7 +124,7 @@ def run_test(path):
param_dict = np.load(path).item() param_dict = np.load(path).item()
pred_config = PredictConfig( pred_config = PredictConfig(
model=Models(), model=Model(),
input_data_mapping=[0], input_data_mapping=[0],
session_init=ParamRestore(param_dict), session_init=ParamRestore(param_dict),
output_var_names=['output:0'] # output:0 is the probability distribution output_var_names=['output:0'] # output:0 is the probability distribution
...@@ -139,7 +139,9 @@ def run_test(path): ...@@ -139,7 +139,9 @@ def run_test(path):
outputs = predict_func([im])[0] outputs = predict_func([im])[0]
prob = outputs[0] prob = outputs[0]
print prob.shape print prob.shape
print prob.argsort()[-10:][::-1] ret = prob.argsort()[-10:][::-1]
print ret
assert ret[0] == 285
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
...@@ -148,7 +150,7 @@ if __name__ == '__main__': ...@@ -148,7 +150,7 @@ if __name__ == '__main__':
if args.gpu: if args.gpu:
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
start_train(get_config()) #start_train(get_config())
# run alexnet with given model (in npy format) # run alexnet with given model (in npy format)
run_test('alexnet-tuned.npy') run_test('alexnet.npy')
...@@ -35,11 +35,12 @@ class PredictConfig(object): ...@@ -35,11 +35,12 @@ class PredictConfig(object):
If not given, defaults to range(len(input_vars)) If not given, defaults to range(len(input_vars))
For example, with image classification task, the testing For example, with image classification task, the testing
dataset only provides datapoints of images (no labels). The dataset only provides datapoints of images (no labels). When
arguments should look like: the input variables of the model is:
inputs: [image_var, label_var] input_vars: [image_var, label_var]
the mapping should look like:
input_data_mapping: [0] input_data_mapping: [0]
If this argument is not set, the inputs and the data points won't be aligned. If this argument is not set in this case, the inputs and the data points won't be aligned.
model: a ModelDesc instance model: a ModelDesc instance
output_var_names: a list of names of the output variable to predict, the output_var_names: a list of names of the output variable to predict, the
variables can be any computable tensor in the graph. variables can be any computable tensor in the graph.
...@@ -53,7 +54,7 @@ class PredictConfig(object): ...@@ -53,7 +54,7 @@ class PredictConfig(object):
assert_type(self.session_config, tf.ConfigProto) assert_type(self.session_config, tf.ConfigProto)
self.session_init = kwargs.pop('session_init') self.session_init = kwargs.pop('session_init')
self.model = kwargs.pop('model') self.model = kwargs.pop('model')
self.input_data_mapping = kwargs.pop('input_dataset_mapping', None) self.input_data_mapping = kwargs.pop('input_data_mapping', None)
self.output_var_names = kwargs.pop('output_var_names', None) self.output_var_names = kwargs.pop('output_var_names', None)
assert len(kwargs) == 0, 'Unknown arguments: {}'.format(str(kwargs.keys())) assert len(kwargs) == 0, 'Unknown arguments: {}'.format(str(kwargs.keys()))
......
Markdown is supported
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