diff --git a/example/sentiment-classification/sentiment_classify.py b/example/sentiment-classification/sentiment_classify.py index 571b4ddcec46c6a748d51672b701f4153a959fad..7fa4a560b8d1c9b222bc0b331278a3e7c7e3776f 100644 --- a/example/sentiment-classification/sentiment_classify.py +++ b/example/sentiment-classification/sentiment_classify.py @@ -124,11 +124,6 @@ def train_net(train_reader, sgd_optimizer = fluid.optimizer.Adagrad(learning_rate=lr) sgd_optimizer.minimize(cost) - # write default main program - with open("./bow_net.backward.program_desc.prototxt", "w") as fo: - program_desc = str(fluid.default_main_program()) - fo.write(program_desc) - # set place, executor, datafeeder place = fluid.CUDAPlace(0) if use_gpu else fluid.CPUPlace() exe = fluid.Executor(place) @@ -221,10 +216,10 @@ def finetune_net(train_reader, fluid.layers.cross_entropy(input=pred, label=label)) acc = fluid.layers.accuracy(input=pred, label=label) - with open("./prototxt/bow_net.forward.program_desc.prototxt", - "w") as fo: - program_desc = str(fluid.default_main_program()) - fo.write(program_desc) + # with open("./prototxt/bow_net.forward.program_desc.prototxt", + # "w") as fo: + # program_desc = str(fluid.default_main_program()) + # fo.write(program_desc) # set optimizer sgd_optimizer = fluid.optimizer.Adagrad(learning_rate=lr) sgd_optimizer.minimize(cost) diff --git a/paddle_hub/module.py b/paddle_hub/module.py index 535a37a52db803893eb55063c95613d509cd2f98..69ad0d866a1d8ba8b0b6422d731bb6373d9dee3a 100644 --- a/paddle_hub/module.py +++ b/paddle_hub/module.py @@ -194,7 +194,7 @@ class Module(object): return lod_tensor def _word_id_mapping(self, inputs): - word_dict = self.config.get_dict() + word_dict = self.config.get_assets_vocab() return list(map(lambda x: word_dict[x], inputs)) @@ -214,7 +214,7 @@ class ModuleConfig(object): self.dict = defaultdict(int) self.dict.setdefault(0) - def get_dict(self): + def get_assets_vocab(self): """ Return dictionary in Module""" return self.dict