Giter Site home page Giter Site logo

paddlepaddle / palm Goto Github PK

View Code? Open in Web Editor NEW
175.0 10.0 30.0 2.27 MB

a Fast, Flexible, Extensible and Easy-to-use NLP Large-scale Pretraining and Multi-task Learning Framework.

Python 99.97% Shell 0.03%
nlp multi-task-learning pretrain-model transformers paddlepaddle baidu

palm's Introduction

PaddlePALM

English | 简体中文

PaddlePALM (PArallel Learning from Multi-tasks) is a fast, flexible, extensible and easy-to-use NLP large-scale pretraining and multi-task learning framework. PaddlePALM is a high level framework aiming at fastly developing high-performance NLP models.

With PaddlePALM, it is easy to achieve effecient exploration of robust learning of NLP models with multiple auxilary tasks. For example, based on PaddlePALM, the produced robust MRC model, D-Net, has achieved the 1st place in EMNLP2019 MRQA track.

Sample

MRQA2019 Leaderboard

Beyond the research scope, PaddlePALM has been applied on Baidu Search Engine to seek for more accurate user query understanding and answer mining, which implies the high reliability and performance of PaddlePALM.

Features:

  • Easy-to-use: with PALM, 8 steps to achieve a typical NLP task. Moreover, all basic components (e.g., the model backbone, dataset reader, task output head, optimizer...) have been decoupled, which allows the replacement of any component to other candidates with quite minor changes of your code.
  • Built-in Popular NLP Backbones and Pre-trained models: multiple state-of-the-art general purpose model architectures and pretrained models (e.g., BERT,ERNIE,RoBERTa,...) are built-in.
  • Easy to play Multi-task Learning: only one API is needed for jointly training of several tasks with parameters reusement.
  • Support train/eval with Multi-GPUs: automatically recognize and adapt to multiple gpus mode to accelerate training and inference.
  • Pre-training friendly: self-supervised tasks (e.g., mask language model) are built-in to facilitate pre-training. Easy to train from scratch.
  • Easy to Customize: support customized development of any component (e.g, backbone, task head, reader and optimizer) with reusement of pre-defined ones, which gives developers high flexibility and effeciency to adapt for diverse NLP scenes.

You can easily re-produce following competitive results with minor codes, which covers most of NLP tasks such as classification, matching, sequence labeling, reading comprehension, dialogue understanding and so on. More details can be found in examples.

Dataset
chnsenticorp Quora Question Pairs matching MSRA-NER
(SIGHAN2006)
CMRC2018

Metric

accuracy
f1-score
accuracy
f1-score
f1-score
em
f1-score
test
test
test
dev
ERNIE Base 95.8 95.8 86.2 82.2 99.2 64.3 85.2

Overview

Sample

Architecture Diagram

PaddlePALM is a well-designed high-level NLP framework. You can efficiently achieve supervised learning, unsupervised/self-supervised learning, multi-task learning and transfer learning with minor codes based on PaddlePALM. There are three layers in PaddlePALM architecture, i.e., component layer, trainer layer and high-level trainer layer from bottom to top.

In component layer, PaddlePALM supplies 6 decoupled components to achieve a NLP task. Each component contains rich pre-defined classes and a Base class. Pre-defined classes are aiming at typical NLP tasks, and the base class is to help users develop a new Class (based on pre-defined ones or from the base).

The trainer layer is to establish a computation graph with selected components and do training and predicting. The training strategy, model saving and loading, evaluation and predicting procedures are described in this layer. Noted a trainer can only process one task.

The high-level trainer layer is for complicated learning and inference strategy, e.g., multi-task learning. You can add auxilary tasks to train robust NLP models (improve test set and out-of-domain performance of a model), or jointly training multiple related tasks to gain more performance for each task.

module illustration
paddlepalm an open source NLP pretraining and multitask learning framework, built on paddlepaddle.
paddlepalm.reader a collection of elastic task-specific dataset readers.
paddlepalm.backbone a collection of classic NLP representation models, e.g., BERT, ERNIE, RoBERTa.
paddlepalm.head a collection of task-specific output layers.
paddlepalm.lr_sched a collection of learning rate schedualers.
paddlepalm.optimizer a collection of optimizers.
paddlepalm.downloader a download module for pretrained models with configure and vocab files.
paddlepalm.Trainer the core unit to start a single task training/predicting session. A trainer is to build computation graph, manage training and evaluation process, achieve model/checkpoint saving and pretrain_model/checkpoint loading.
paddlepalm.MultiHeadTrainer the core unit to start a multi-task training/predicting session. A MultiHeadTrainer is built based on several Trainers. Beyond the inheritance of Trainer, it additionally achieves model backbone reuse across tasks, trainer sampling for multi-task learning, and multi-head inference for effective evaluation and prediction.

Installation

PaddlePALM support both python2 and python3, linux and windows, CPU and GPU. The preferred way to install PaddlePALM is via pip. Just run following commands in your shell.

pip install paddlepalm

Installing via source

git clone https://github.com/PaddlePaddle/PALM.git
cd PALM && python setup.py install

Library Dependencies

  • Python >= 2.7
  • cuda >= 9.0
  • cudnn >= 7.0
  • PaddlePaddle >= 1.7.0 (Please refer to this to install)

Downloading pretrain models

We incorporate many pretrained models to initialize model backbone parameters. Training big NLP model, e.g., 12-layer transformers, with pretrained models is practically much more effective than that with randomly initialized parameters. To see all the available pretrained models and download, run following code in python interpreter (input command python in shell):

>>> from paddlepalm import downloader
>>> downloader.ls('pretrain')
Available pretrain items:
  => RoBERTa-zh-base
  => RoBERTa-zh-large
  => ERNIE-v2-en-base
  => ERNIE-v2-en-large
  => XLNet-cased-base
  => XLNet-cased-large
  => ERNIE-v1-zh-base
  => ERNIE-v1-zh-base-max-len-512
  => BERT-en-uncased-large-whole-word-masking
  => BERT-en-cased-large-whole-word-masking
  => BERT-en-uncased-base
  => BERT-en-uncased-large
  => BERT-en-cased-base
  => BERT-en-cased-large
  => BERT-multilingual-uncased-base
  => BERT-multilingual-cased-base
  => BERT-zh-base

>>> downloader.download('pretrain', 'BERT-en-uncased-base', './pretrain_models')
...

Usage

Quick Start

8 steps to start a typical NLP training task.

  1. use paddlepalm.reader to create a reader for dataset loading and input features generation, then call reader.load_data method to load your training data.
  2. use paddlepalm.backbone to create a model backbone to extract text features (e.g., contextual word embedding, sentence embedding).
  3. register your reader with your backbone through reader.register_with method. After this step, your reader is able to yield input features used by backbone.
  4. use paddlepalm.head to create a task output head. This head can provide task loss for training and predicting results for model inference.
  5. create a task trainer with paddlepalm.Trainer, then build forward graph with backbone and task head (created in step 2 and 4) through trainer.build_forward.
  6. use paddlepalm.optimizer (and paddlepalm.lr_sched if is necessary) to create a optimizer, then build backward through trainer.build_backward.
  7. fit prepared reader and data (achieved in step 1) to trainer with trainer.fit_reader method.
  8. load pretrain model with trainer.load_pretrain, or load checkpoint with trainer.load_ckpt or nothing to do for training from scratch, then do training with trainer.train.

For more implementation details, see following demos:

Multi-task Learning

To run with multi-task learning mode:

  1. repeatedly create components (i.e., reader, backbone and head) for each task followed with step 1~5 above.
  2. create empty trainers (each trainer is corresponded to one task) and pass them to create a MultiHeadTrainer.
  3. build multi-task forward graph with multi_head_trainer.build_forward method.
  4. use paddlepalm.optimizer (and paddlepalm.lr_sched if is necessary) to create a optimizer, then build backward through multi_head_trainer.build_backward.
  5. fit all prepared readers and data to multi_head_trainer with multi_head_trainer.fit_readers method.
  6. load pretrain model with multi_head_trainer.load_pretrain, or load checkpoint with multi_head_trainer.load_ckpt or nothing to do for training from scratch, then do training with multi_head_trainer.train.

The save/load and predict operations of a multi_head_trainer is the same as a trainer.

For more implementation details with multi_head_trainer, see

Save models

To save models/checkpoints and logs during training, just call trainer.set_saver method. More implementation details see this.

Evaluation/Inference

To do predict/evaluation after a training stage, just create another three reader, backbone and head instance with phase='predict' (repeat step 1~4 above). Then do predicting with predict method in trainer (no need to create another trainer). More implementation details see this.

If you want to do evaluation during training process, use trainer.train_one_step() instead of trainer.train(). The trainer.train_one_step(batch) achieves to train only one step, thus you can insert evaluation code into any point of training process. The argument batch can be fetched from trainer.get_one_batch.

PaddlePALM also supports multi-head inference, please reference examples/multi-task/joint_predict.py.

Play with Multiple GPUs

If there exists multiple GPUs in your environment, you can control the number and index of these GPUs through the environment variable CUDA_VISIBLE_DEVICES. For example, if 4 GPUs in your enviroment, indexed with 0,1,2,3, you can run with GPU2 only with following commands

CUDA_VISIBLE_DEVICES=2 python run.py

Multiple GPUs should be seperated with ,. For example, running with GPU2 and GPU3, following commands is refered:

CUDA_VISIBLE_DEVICES=2,3 python run.py

On multi-gpu mode, PaddlePALM will automatically split each batch onto the available cards. For example, if the batch_size is set 64, and there are 4 cards visible for PaddlePALM, then the batch_size in each card is actually 64/4=16. Therefore, when running with multiple cards, you need to ensure that the set batch_size can be divided by the number of cards.

License

This tutorial is contributed by PaddlePaddle and licensed under the Apache-2.0 license.

palm's People

Contributors

0yuanzhang0 avatar jesseyxujin avatar wangxiao1021 avatar xiaoguanghu01 avatar xixiaoyao avatar xyzhou-puck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

palm's Issues

在jupyter notebook 运行报错?

如图,在jupyter notebook 下运行报错,经过重装paddle,重启jupyter ,重启系统的情况下仍然如此,不知道为何,希望能帮忙查找下原因,感谢.

Selection_057

具体报错信息如下:

`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 import paddlepalm

~/anaconda3/lib/python3.7/site-packages/paddlepalm/init.py in
5 from . import lr_sched
6 from . import backbone
----> 7 from . import reader
8 from . import head
9

~/anaconda3/lib/python3.7/site-packages/paddlepalm/reader/init.py in
1
----> 2 from .cls import ClassifyReader
3 from .match import MatchReader
4 from .seq_label import SequenceLabelReader
5 from .mrc import MRCReader

~/anaconda3/lib/python3.7/site-packages/paddlepalm/reader/cls.py in
15
16 from paddlepalm.reader.base_reader import Reader
---> 17 from paddlepalm.reader.utils.reader4ernie import ClassifyReader as CLSReader
18
19

~/anaconda3/lib/python3.7/site-packages/paddlepalm/reader/utils/reader4ernie.py in
40 if six.PY3:
41 import io
---> 42 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
43 sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
44

AttributeError: 'OutStream' object has no attribute 'buffer'`

设计缺陷,classify head的后处理不返回输出,仅支持输出到文件

trainer里的predict是可以不传入output_dir并将results返回的,但是predict函数是调用分类头里的后处理函数处理返回results的,而分类头里后处理函数却没有相应的处理。不传入output_dir会抛出异常。希望该函数在不传入output_dir时返回results
源码:PALM/paddlepalm/head/cls.py

def epoch_postprocess(self, post_inputs, output_dir=None):
        # there is no post_inputs needed and not declared in epoch_inputs_attrs, hence no elements exist in post_inputs
        if not self._is_training:
            if output_dir is None:
                raise ValueError('argument output_dir not found in config. Please add it into config dict/file.')
            with open(os.path.join(output_dir, 'predictions.json'), 'w') as writer:
                for i in range(len(self._preds)):
                    label = int(np.argmax(np.array(self._preds[i])))
                    result = {'index': i, 'label': label, 'logits': self._preds[i], 'probs': self._probs[i]}
                    result = json.dumps(result)
                    writer.write(result+'\n')
            print('Predictions saved at '+os.path.join(output_dir, 'predictions.json'))

其他head的后处理函数也有相同的问题,建议都修改一下,谢谢。

函数引用出错

paddle.fluid.layers中并没有switch_case函数,在paddle的官网API指南中也没有找到相关函数。

File "/media/dsy/PALM-master/paddlepalm/mtl_controller.py", line 502, in _init_train
loss = layers.switch_case(
AttributeError: module 'paddle.fluid.layers' has no attribute 'switch_case'

Perhaps the main_program is not set to ParallelExecutor.

I0427 14:37:27.545102 21654 parallel_executor.cc:440] The Program will be executed on CUDA using ParallelExecutor, 1 cards are used, so 1 programs are executed in parallel.
I0427 14:37:27.635213 21654 build_strategy.cc:365] SeqOnlyAllReduceOps:0, num_trainers:1
I0427 14:37:27.762869 21654 parallel_executor.cc:307] Inplace strategy is enabled, when build_strategy.enable_inplace = True
I0427 14:37:27.837890 21654 parallel_executor.cc:375] Garbage collection strategy is enabled, when FLAGS_eager_delete_tensor_gb = 0
./python_paddle/lib/python3.6/site-packages/paddle/fluid/executor.py:782: UserWarning: The following exception is not an EOF exception.
"The following exception is not an EOF exception.")
Traceback (most recent call last):
File "./python_paddle/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "./python_paddle/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "test.py", line 140, in
trainer.train(print_steps=print_steps)
File "./python_paddle/lib/python3.6/site-packages/paddlepalm/multihead_trainer.py", line 226, in train
rt_outputs, task_id = self.train_one_step(feed)
File "./python_paddle/lib/python3.6/site-packages/paddlepalm/multihead_trainer.py", line 282, in train_one_step
rt_outputs = self._trainers[task_id].train_one_step(batch)
File "./python_paddle/lib/python3.6/site-packages/paddlepalm/trainer.py", line 742, in train_one_step
rt_outputs = exe.run(distribute_train_prog, feed=feed, fetch_list=fetch_list)
File "./python_paddle/lib/python3.6/site-packages/paddle/fluid/executor.py", line 783, in run
six.reraise(*sys.exc_info())
File "./python_paddle/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "./python_paddle/lib/python3.6/site-packages/paddle/fluid/executor.py", line 778, in run
use_program_cache=use_program_cache)
File "./python_paddle/lib/python3.6/site-packages/paddle/fluid/executor.py", line 843, in _run_impl
return_numpy=return_numpy)
File "./python_paddle/lib/python3.6/site-packages/paddle/fluid/executor.py", line 677, in _run_parallel
tensors = exe.run(fetch_var_names)._move_to_list()
paddle.fluid.core_avx.EnforceNotMet:


C++ Call Stacks (More useful to developers):

0 std::string paddle::platform::GetTraceBackString<std::string const&>(std::string const&, char const*, int)
1 paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int)
2 paddle::framework::details::FastThreadedSSAGraphExecutor::InsertFetchOps(std::vector<std::string, std::allocatorstd::string > const&, std::vector<paddle::framework::LoDTensor, std::allocatorpaddle::framework::LoDTensor >, std::unordered_map<std::string, std::vector<paddle::framework::details::VarHandleBase, std::allocatorpaddle::framework::details::VarHandleBase* >, std::hashstd::string, std::equal_tostd::string, std::allocator<std::pair<std::string const, std::vector<paddle::framework::details::VarHandleBase*, std::allocatorpaddle::framework::details::VarHandleBase* > > > >, std::unordered_map<paddle::framework::details::OpHandleBase, std::atomic, std::hashpaddle::framework::details::OpHandleBase*, std::equal_topaddle::framework::details::OpHandleBase*, std::allocator<std::pair<paddle::framework::details::OpHandleBase* const, std::atomic > > >, std::vector<paddle::framework::details::OpHandleBase, std::allocatorpaddle::framework::details::OpHandleBase* >, std::vector<paddle::framework::details::OpHandleBase, std::allocatorpaddle::framework::details::OpHandleBase* >*)
3 paddle::framework::details::FastThreadedSSAGraphExecutor::Run(std::vector<std::string, std::allocatorstd::string > const&)
4 paddle::framework::details::ScopeBufferedMonitor::Apply(std::function<void ()> const&, bool)
5 paddle::framework::details::ScopeBufferedSSAGraphExecutor::Run(std::vector<std::string, std::allocatorstd::string > const&)
6 paddle::framework::ParallelExecutor::Run(std::vector<std::string, std::allocatorstd::string > const&)


Error Message Summary:

PreconditionNotMetError: Cannot find fetched variable(dvqa.tmp_1). Perhaps the main_program is not set to ParallelExecutor.
[Hint: Expected fetched_var_it != fetched_vars->end(), but received fetched_var_it == fetched_vars->end().] at (/paddle/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc:147)

cpu和gpu同时使用问题

我已经在gpu上训练完了基于palm的模型,预测的话可以实现请问可以实现在cpu和gpu上都能运行吗?
我把palm依赖于paddle关于cuda的代码注释掉是可以在cpu上跑的。但是要实现cpu和gpu同时运行(留一个use_gpu=True/False)的属性,是需要对paddle.fluid.core_avx'的 'get_cuda_device_count进行修改吗

paddlepalm安装中报错

环境:aistudio 高端版 python3.7 PaddlePaddle 1.7.1

在命令行里安装之后测试正常,在notebook里面测试就报错。
在notebook里面运行:from paddlepalm import downloader

---------------------------------------------------------------------------AttributeError Traceback (most recent call last) in
----> 1 from paddlepalm import downloader
2 downloader.ls('pretrain')
~/extlib/paddlepalm/init.py in
5 from . import lr_sched
6 from . import backbone
----> 7 from . import reader
8 from . import head
9
~/extlib/paddlepalm/reader/init.py in
1
----> 2 from .cls import ClassifyReader
3 from .match import MatchReader
4 from .seq_label import SequenceLabelReader
5 from .mrc import MRCReader
~/extlib/paddlepalm/reader/cls.py in
15
16 from paddlepalm.reader.base_reader import Reader
---> 17 from paddlepalm.reader.utils.reader4ernie import ClassifyReader as CLSReader
18
19
~/extlib/paddlepalm/reader/utils/reader4ernie.py in
40 if six.PY3:
41 import io
---> 42 sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
43 sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
44
AttributeError: 'OutStream' object has no attribute 'buffer'

我在执行run.sh遇到问题

creating readers...
loading mrqa training data...
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/io.py:721: DeprecationWarning: The 'warn' function is deprecated, use 'warning' instead
'paddle.fluid.layers.py_reader() may be deprecated in the near future. '
WARNING:root:paddle.fluid.layers.py_reader() may be deprecated in the near future. Please use paddle.fluid.io.DataLoader.from_generator() instead.
Traceback (most recent call last):
File "mtl_run.py", line 397, in
train(multitask_config)
File "mtl_run.py", line 134, in train
joint_generator, train_pyreader, model_inputs = create_reader("train_reader", train_input_shape, True, task_map_id, gens)
File "reader/joint_reader.py", line 84, in create_reader
pyreader, model_inputs = placeholder.build(capacity=16, reader_name=reader_name)
File "/home/aistudio/multi_task_learning/PALM/utils/placeholder.py", line 64, in build
use_double_buffer = use_double_buffer)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/io.py", line 729, in py_reader
use_double_buffer=use_double_buffer)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/io.py", line 453, in _py_reader
'ranks': ranks
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3009, in append_op
kwargs.get("stop_gradient", False))
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/tracer.py", line 45, in trace_op
not stop_gradient)
ValueError: (InvalidArgument) Python object is not type of St10shared_ptrIN6paddle10imperative7VarBaseEE (at /paddle/paddle/fluid/pybind/imperative.cc:221)

paddle 版本

现在已发布的paddle版本最高为1.6
而PALM要求1.7

PALM梯度更新问题

有三个问题请教:
(1)有关多任务梯度更新的,我对代码理解是这样的:(multi_task/run.py)
task1: 产生loss1,更新一次模型参数
task2:产生loss2,在上一次梯度更新基础上再更新一次
不断循环上述两个过程

(2)下面粘贴train.py中build_backward函数部分代码
我理解 param_list中就是存放模型参数值,那么updated_param = param - param_list[param.name] * weight_decay * optimizer.get_cur_learning_rate() 这个表达式,表示这个参数更新是这个参数值减去这个参数值乘以一个系数。这里就没有使用梯度值。参数更新,不是 w = w - alpha * grad_w吗?

def build_backward(self, optimizer, weight_decay=None, use_ema=False, ema_decay=None):
    """
    Build backward computation graph and training strategy.

    Arguments:
        - optimizer: 
        - weight_decay: optional, default is None (disable weight decay).
        - use_ema: optional, default is False. The flag to control whether to apply Exponential Moving Average strategy on parameter updates.
        - ema_decay: optional, default is None. Only works with use_ema == True. Control decay rate of EMA strategy.

    """
    # build optimizer
    assert self._loss_var is not None and self._train_init_prog is not None, "train graph not foung! You should build_forward first."
    optimizer._set_prog(self._train_prog, self._train_init_prog)
    with fluid.program_guard(self._train_prog, self._train_init_prog):
        param_grads = optimizer._build()

            for param, grad in param_grads:
                if exclude_from_weight_decay(param.name):
                    continue
                with param.block.program._optimized_guard(
                    [param, grad]), fluid.framework.name_scope("weight_decay"):
                    updated_param = param - param_list[
                        param.name] * weight_decay * optimizer.get_cur_learning_rate()
                    fluid.layers.assign(output=param, input=updated_param)

        if use_ema:
            ema = fluid.optimizer.ExponentialMovingAverage(ema_decay)
            ema.update()

    self._exe.run(self._train_init_prog)

(3)PLAM是针对NLP的的多任务框架,有没有针对图像方面的多任务框架发布?

报一个小bug,用num_fakes做切片时没有取整。

报错信息:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-039e026fb8a7> in <module>
     30 # step 8: predict
     31 print('predicting..')
---> 32 results = trainer.predict(print_steps=print_steps)

~/anaconda3/envs/paddle/lib/python3.6/site-packages/paddlepalm/trainer.py in predict(self, output_dir, print_steps)
    645         cur_predict_step = 0
    646         for feed in iterator:
--> 647             rt_outputs = self.predict_one_batch(feed)
    648             # rt_outputs = {k[len(self.name+'.'):]: v for k,v in rt_outputs.items() if k.startswith(self.name+'.')}
    649             self._pred_head.batch_postprocess(rt_outputs)

~/anaconda3/envs/paddle/lib/python3.6/site-packages/paddlepalm/trainer.py in predict_one_batch(self, batch)
    752             num_fakes = decode_fake(len(rt_outputs[0]), mask, self._predict_batch_size)
    753             if num_fakes:
--> 754                 rt_outputs = [i[:-num_fakes] for i in rt_outputs]
    755         else:
    756             feed = self._pred_feed_batch_process_fn(batch)

~/anaconda3/envs/paddle/lib/python3.6/site-packages/paddlepalm/trainer.py in <listcomp>(.0)
    752             num_fakes = decode_fake(len(rt_outputs[0]), mask, self._predict_batch_size)
    753             if num_fakes:
--> 754                 rt_outputs = [i[:-num_fakes] for i in rt_outputs]
    755         else:
    756             feed = self._pred_feed_batch_process_fn(batch)

TypeError: slice indices must be integers or None or have an __index__ method

Debug:

ipdb> num_fakes
6.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.