Skip to content

Commit edd2132

Browse files
committed
remove conflict
2 parents c9641a0 + 4b3e22b commit edd2132

File tree

513 files changed

+8336
-5969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

513 files changed

+8336
-5969
lines changed

.copyright.hook

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
from __future__ import absolute_import
2+
from __future__ import print_function
3+
from __future__ import unicode_literals
4+
5+
import argparse
6+
import io, re
7+
import sys, os
8+
import subprocess
9+
import platform
10+
11+
COPYRIGHT = '''
12+
Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
13+
14+
Licensed under the Apache License, Version 2.0 (the "License");
15+
you may not use this file except in compliance with the License.
16+
You may obtain a copy of the License at
17+
18+
http://www.apache.org/licenses/LICENSE-2.0
19+
20+
Unless required by applicable law or agreed to in writing, software
21+
distributed under the License is distributed on an "AS IS" BASIS,
22+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
See the License for the specific language governing permissions and
24+
limitations under the License.
25+
'''
26+
27+
LANG_COMMENT_MARK = None
28+
29+
NEW_LINE_MARK = None
30+
31+
COPYRIGHT_HEADER = None
32+
33+
if platform.system() == "Windows":
34+
NEW_LINE_MARK = "\r\n"
35+
else:
36+
NEW_LINE_MARK = '\n'
37+
COPYRIGHT_HEADER = COPYRIGHT.split(NEW_LINE_MARK)[1]
38+
p = re.search('(\d{4})', COPYRIGHT_HEADER).group(0)
39+
process = subprocess.Popen(["date", "+%Y"], stdout=subprocess.PIPE)
40+
date, err = process.communicate()
41+
date = date.decode("utf-8").rstrip("\n")
42+
COPYRIGHT_HEADER = COPYRIGHT_HEADER.replace(p, date)
43+
44+
45+
def generate_copyright(template, lang='C'):
46+
if lang == 'Python':
47+
LANG_COMMENT_MARK = '#'
48+
else:
49+
LANG_COMMENT_MARK = "//"
50+
51+
lines = template.split(NEW_LINE_MARK)
52+
ans = LANG_COMMENT_MARK + " " + COPYRIGHT_HEADER + NEW_LINE_MARK
53+
for lino, line in enumerate(lines):
54+
if lino == 0 or lino == 1 or lino == len(lines) - 1: continue
55+
ans += LANG_COMMENT_MARK + " " + line + NEW_LINE_MARK
56+
57+
return ans + "\n"
58+
59+
60+
def lang_type(filename):
61+
if filename.endswith(".py"):
62+
return "Python"
63+
elif filename.endswith(".h"):
64+
return "C"
65+
elif filename.endswith(".hpp"):
66+
return "C"
67+
elif filename.endswith(".cc"):
68+
return "C"
69+
elif filename.endswith(".cpp"):
70+
return "C"
71+
elif filename.endswith(".cu"):
72+
return "C"
73+
elif filename.endswith(".cuh"):
74+
return "C"
75+
elif filename.endswith(".go"):
76+
return "C"
77+
elif filename.endswith(".proto"):
78+
return "C"
79+
else:
80+
print("Unsupported filetype")
81+
exit(0)
82+
83+
84+
def main(argv=None):
85+
parser = argparse.ArgumentParser(
86+
description='Checker for copyright declaration.')
87+
parser.add_argument('filenames', nargs='*', help='Filenames to check')
88+
args = parser.parse_args(argv)
89+
90+
retv = 0
91+
for filename in args.filenames:
92+
first_line = io.open(filename).readline()
93+
if "COPYRIGHT" in first_line.upper() : continue
94+
original_contents = io.open(filename).read()
95+
new_contents = generate_copyright(
96+
COPYRIGHT, lang_type(filename)) + original_contents
97+
print('Auto Insert Copyright Header {}'.format(filename))
98+
retv = 1
99+
with io.open(filename, 'w') as output_file:
100+
output_file.write(new_contents)
101+
102+
return retv
103+
104+
105+
if __name__ == '__main__':
106+
exit(main())

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@
3131
- id: go-fmt
3232
types:
3333
- go
34+
- repo: local
35+
hooks:
36+
- id: copyright_checker
37+
name: copyright_checker
38+
entry: python ./.copyright.hook
39+
language: system
40+
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$
41+
exclude: (?!.*third_party)^.*$ | (?!.*book)^.*$

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CODE_OF_CONDUCT_cn.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# 貢獻者公約
2+
3+
## 我們的承諾
4+
5+
為了促進一個開放透明且受歡迎的環境,我們作為貢獻者和維護者保證,無論年齡、種族、民族、性別認同和表達、體型、殘疾、經驗水平、國籍、個人表現、宗教或性別取向,在我們的專案以及社群的參與者都有不被騷擾的體驗。
6+
7+
## 我們的準則
8+
9+
舉例來說有助於創造正面環境的行為包括:
10+
* 使用歡迎和包容性語言
11+
* 尊重不同的觀點和經驗
12+
* 優雅地接受建設性批評
13+
* 關注在對於社群最好的事情上
14+
* 對其他社群成員的表現友善
15+
16+
舉例來說身為參與者不能接受的行為包括:
17+
* 使用與性有關的言語或是圖像,以及不受歡迎的性騷擾
18+
* 酸民/反串/釣魚行為或進行侮辱/貶損的評論,人身攻擊及政治攻擊
19+
* 公開或私下的騷擾
20+
* 未經許可地發布他人的個人資料,例如住址或是電子地址
21+
* 其他可以被合理地認定為不恰當或者違反職業操守的行為
22+
23+
## 我們的責任
24+
25+
專案維護者有責任為"可接受的行為"準則做出詮釋,以及對已發生的不被接受的行為採取恰當且公平的糾正措施。
26+
27+
專案維護者有權力及責任去刪除、編輯、拒絕與本行為準則有所違背的評論(comments)、提交(commits)、程式碼、wiki 編輯、問題(issues)和其他貢獻,以及專案維護者可暫時或永久性的禁止任何他們認為有不適當、威脅、冒犯、有害行為的貢獻者。
28+
29+
## 使用範圍
30+
31+
當一個人代表該專案或是其社群時,本行為準則適用於其專案平台和公共平台。
32+
33+
代表專案或是社群的情況,舉例來說包括使用官方專案的電子郵件地址、通過官方的社群媒體帳號發布或線上或線下事件中擔任指定代表。
34+
35+
該專案的呈現方式可由其專案維護者進行進一步的定義及解釋。
36+
37+
## 強制執行
38+
39+
可以透過[email protected],來聯繫專案團隊來報告濫用、騷擾或其他不被接受的行為。
40+
41+
任何維護團隊認為有必要且適合的所有投訴都將進行審查及調查,並做出相對應的回應。專案小組有對事件回報者有保密的義務。具體執行的方針近一步細節可能會單獨公佈。
42+
43+
沒有真誠的遵守或是執行本行為準則的專案維護人員,可能會因專案領導人或是其他成員的決定,暫時或是永久的取消其身份。
44+
45+
## 來源
46+
47+
本行為準則改編自[貢獻者公約][首頁],版本 1.4
48+
可在此觀看https://www.contributor-covenant.org/zh-tw/version/1/4/code-of-conduct.html
49+
50+
[首頁]: https://www.contributor-covenant.org

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Please refer to our [release announcement](https://github.com/PaddlePaddle/Paddl
3737

3838
- Optimized math operations through SSE/AVX intrinsics, BLAS libraries
3939
(e.g. MKL, OpenBLAS, cuBLAS) or customized CPU/GPU kernels.
40+
- Optimized CNN networks through MKL-DNN library.
4041
- Highly optimized recurrent networks which can handle **variable-length**
4142
sequence without padding.
4243
- Optimized local and distributed training for models with high dimensional

adversarial/advbox/attacks/base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
#Licensed under the Apache License, Version 2.0 (the "License");
4+
#you may not use this file except in compliance with the License.
5+
#You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
#Unless required by applicable law or agreed to in writing, software
10+
#distributed under the License is distributed on an "AS IS" BASIS,
11+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
#See the License for the specific language governing permissions and
13+
#limitations under the License.
114
"""
215
The base model of the model.
316
"""

adversarial/advbox/attacks/gradientsign.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
#Licensed under the Apache License, Version 2.0 (the "License");
4+
#you may not use this file except in compliance with the License.
5+
#You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
#Unless required by applicable law or agreed to in writing, software
10+
#distributed under the License is distributed on an "AS IS" BASIS,
11+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
#See the License for the specific language governing permissions and
13+
#limitations under the License.
114
"""
215
This module provide the attack method for FGSM's implement.
316
"""
@@ -36,3 +49,39 @@ def _apply(self, image_label, epsilons=1000):
3649

3750

3851
FGSM = GradientSignAttack
52+
53+
54+
class IteratorGradientSignAttack(Attack):
55+
"""
56+
This attack was originally implemented by Alexey Kurakin(Google Brain).
57+
Paper link: https://arxiv.org/pdf/1607.02533.pdf
58+
"""
59+
60+
def _apply(self, image_label, epsilons=100, steps=10):
61+
"""
62+
Apply the iterative gradient sign attack.
63+
Args:
64+
image_label(list): The image and label tuple list of one element.
65+
epsilons(list|tuple|int): The epsilon (input variation parameter).
66+
steps(int): The number of iterator steps.
67+
Return:
68+
numpy.ndarray: The adversarail sample generated by the algorithm.
69+
"""
70+
assert len(image_label) == 1
71+
pre_label = np.argmax(self.model.predict(image_label))
72+
gradient = self.model.gradient(image_label)
73+
min_, max_ = self.model.bounds()
74+
75+
if not isinstance(epsilons, Iterable):
76+
epsilons = np.linspace(0, 1, num=epsilons + 1)
77+
78+
for epsilon in epsilons:
79+
adv_img = image_label[0][0].reshape(gradient.shape)
80+
for _ in range(steps):
81+
gradient = self.model.gradient([(adv_img, image_label[0][1])])
82+
gradient_sign = np.sign(gradient) * (max_ - min_)
83+
adv_img = adv_img + epsilon * gradient_sign
84+
adv_img = np.clip(adv_img, min_, max_)
85+
adv_label = np.argmax(self.model.predict([(adv_img, 0)]))
86+
if pre_label != adv_label:
87+
return adv_img

adversarial/advbox/models/base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
#Licensed under the Apache License, Version 2.0 (the "License");
4+
#you may not use this file except in compliance with the License.
5+
#You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
#Unless required by applicable law or agreed to in writing, software
10+
#distributed under the License is distributed on an "AS IS" BASIS,
11+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
#See the License for the specific language governing permissions and
13+
#limitations under the License.
114
"""
215
The base model of the model.
316
"""

adversarial/advbox/models/paddle.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
#Licensed under the Apache License, Version 2.0 (the "License");
4+
#you may not use this file except in compliance with the License.
5+
#You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
#Unless required by applicable law or agreed to in writing, software
10+
#distributed under the License is distributed on an "AS IS" BASIS,
11+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
#See the License for the specific language governing permissions and
13+
#limitations under the License.
114
from __future__ import absolute_import
215

316
import numpy as np

adversarial/fluid_mnist.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
2+
#
3+
#Licensed under the Apache License, Version 2.0 (the "License");
4+
#you may not use this file except in compliance with the License.
5+
#You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
#Unless required by applicable law or agreed to in writing, software
10+
#distributed under the License is distributed on an "AS IS" BASIS,
11+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
#See the License for the specific language governing permissions and
13+
#limitations under the License.
114
"""
215
CNN on mnist data using fluid api of paddlepaddle
316
"""

0 commit comments

Comments
 (0)