Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Add loss, save_inference_model and logger#53

Merged
LielinJiang merged 19 commits intoPaddlePaddle:masterfrom
LielinJiang:loss-export
Apr 27, 2020
Merged

Add loss, save_inference_model and logger#53
LielinJiang merged 19 commits intoPaddlePaddle:masterfrom
LielinJiang:loss-export

Conversation

@LielinJiang
Copy link
Collaborator

@LielinJiang LielinJiang commented Apr 24, 2020

  1. move Loss from model.py to loss.py
  2. add save_inference_model
  3. add logger
  4. add unittest for multiple gpus train,eval and predict; transform; datasets; models;loss;logger.
  5. add some comments
  6. fix bug

hapi/logger.py Outdated
local_rank = ParallelEnv().local_rank
if local_rank == 0:
ch = logging.StreamHandler(stream=sys.stdout)
ch.setLevel(logging.DEBUG)
Copy link
Collaborator

@heavengate heavengate Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be set as log_level ? same as below

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

hapi/loss.py Outdated
@@ -0,0 +1,103 @@
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019 -> 2020

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

hapi/loss.py Outdated
__all__ = ['Loss', 'CrossEntropy', 'SoftmaxWithCrossEntropy']


def to_list(value):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move these common functions to utils.py ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

@@ -0,0 +1,179 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
Copy link
Collaborator

@heavengate heavengate Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move tests directory to under hapi/ will make whl contains test scripts, do we mean this? OTOH, move tests directory here, tests directory outside should be deleted?

Copy link
Collaborator Author

@LielinJiang LielinJiang Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看了下incubate目录,fleet下也有个test文件夹。把根目录下的tests删除了。到时候挪到框架中,还可以再变一下tests的目录

from hapi.download import get_weights_path
from hapi.model import Model
from hapi.loss import Loss
from hapi.download import get_weights_path_from_url
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个名字有点长,是否从url,可以内部判断吧,可以直接用download吗? 返回weight的path

hapi/model.py Outdated
params_filename(str|None): The name of file to save all related parameters.
If it is set None, parameters will be saved
in separate files .
export_for_deployment(bool): If True, programs are modified to only support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面调用fluid.io.save_inference_model时始终传入的 infer_prog,而export_for_deployment=False时描述是为了训练。 这里觉得可以先把export_for_deployment参数去掉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,thanks

return x


class MNIST(Model):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

内部已经封装了LeNet了,觉得可以用,这里就不用写这些了

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

heavengate
heavengate previously approved these changes Apr 27, 2020
hapi/logger.py Outdated
logger.propagate = False

format_str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logging.basicConfig(format=format_str, level=log_level)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we'd better not to use logging.basicConfig, it seems make user's logging setting ignored afterwards. See PaddlePaddle/Paddle#17786

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks.

hapi/logger.py Outdated
from paddle.fluid.dygraph.parallel import ParallelEnv


@functools.lru_cache()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be python version incompatibility for functools.lru_cache

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, thanks.

@LielinJiang LielinJiang merged commit 2c6d409 into PaddlePaddle:master Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants