Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_38905368
tensorflow
提交
1b65fb67
T
tensorflow
项目概览
qq_38905368
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1b65fb67
编写于
6月 24, 2016
作者:
M
Martin Wicke
提交者:
TensorFlower Gardener
6月 24, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add deprecation decorators. Deprecate dnn_ops.dnn.
Change: 125830566
上级
3fc8c834
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
118 addition
and
0 deletion
+118
-0
tensorflow/contrib/framework/BUILD
tensorflow/contrib/framework/BUILD
+1
-0
tensorflow/contrib/framework/__init__.py
tensorflow/contrib/framework/__init__.py
+2
-0
tensorflow/contrib/framework/python/framework/__init__.py
tensorflow/contrib/framework/python/framework/__init__.py
+1
-0
tensorflow/contrib/framework/python/framework/deprecation.py
tensorflow/contrib/framework/python/framework/deprecation.py
+112
-0
tensorflow/contrib/learn/python/learn/ops/dnn_ops.py
tensorflow/contrib/learn/python/learn/ops/dnn_ops.py
+2
-0
未找到文件。
tensorflow/contrib/framework/BUILD
浏览文件 @
1b65fb67
...
...
@@ -14,6 +14,7 @@ py_library(
srcs
=
[
"__init__.py"
,
"python/framework/__init__.py"
,
"python/framework/deprecation.py"
,
"python/framework/tensor_util.py"
,
"python/ops/__init__.py"
,
"python/ops/arg_scope.py"
,
...
...
tensorflow/contrib/framework/__init__.py
浏览文件 @
1b65fb67
...
...
@@ -28,6 +28,8 @@
@@with_shape
@@with_same_shape
## Deprecation
@@deprecated
## Arg_Scope
@@arg_scope
...
...
tensorflow/contrib/framework/python/framework/__init__.py
浏览文件 @
1b65fb67
...
...
@@ -19,4 +19,5 @@ from __future__ import division
from
__future__
import
print_function
# pylint: disable=wildcard-import
from
tensorflow.contrib.framework.python.framework.deprecation
import
deprecated
from
tensorflow.contrib.framework.python.framework.tensor_util
import
*
tensorflow/contrib/framework/python/framework/deprecation.py
0 → 100644
浏览文件 @
1b65fb67
# pylint: disable=g-bad-file-header
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tensor utility functions."""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
re
from
tensorflow.python.platform
import
tf_logging
as
logging
def
_get_qualified_name
(
function
):
# Python 3
if
hasattr
(
'__qualname__'
,
function
):
return
function
.
__qualname__
# Python 2
if
hasattr
(
'im_class'
,
function
):
return
function
.
im_class
.
__name__
+
'.'
+
function
.
__name__
return
function
.
__name__
def
_add_deprecation_to_docstring
(
doc
,
date
,
instructions
):
"""Adds a deprecation notice to a docstring."""
lines
=
doc
.
splitlines
()
lines
[
0
]
+=
' (deprecated)'
notice
=
[
''
,
'THIS FUNCTION IS DEPRECATED. It will be removed after %s.'
%
date
,
'Instructions for updating:'
,
'%s'
%
instructions
,
]
if
len
(
lines
)
>
1
:
# Make sure that we keep our distance from the main body
if
lines
[
1
].
strip
():
notice
+=
[
''
]
lines
=
[
lines
[
0
]]
+
notice
+
lines
[
1
:]
else
:
lines
+=
notice
return
'
\n
'
.
join
(
lines
)
def
deprecated
(
date
,
instructions
):
"""Decorator for marking functions or methods deprecated.
This decorator adds a deprecation warning to a function's docstring. It has
the following format:
<function> (from <module>) is deprecated and will be removed after <date>.
Instructions for updating:
<instructions>
whenever the decorated function is called. <function> will include the class
name if it is a method.
It also edits the docstring of the function: ' (deprecated)' is appended
to the first line of the docstring and a deprecation notice is prepended
to the rest of the docstring.
Args:
date: String. The date the function is scheduled to be removed. Must be
ISO 8601 (YYYY-MM-DD).
instructions: String. Instructions on how to update code using the
deprecated function.
Returns:
Decorated function or method.
Raises:
ValueError: If date is not in ISO 8601 format, or instructions are empty.
"""
if
not
date
:
raise
ValueError
(
'Tell us what date this will be deprecated!'
)
if
not
re
.
match
(
r
'20\d\d-[01]\d-[0123]\d'
,
date
):
raise
ValueError
(
'Date must be YYYY-MM-DD.'
)
if
not
instructions
:
raise
ValueError
(
'Don
\'
t deprecate things without conversion instructions!'
)
def
deprecated_wrapper
(
func
):
"""Deprecation wrapper."""
def
new_func
(
*
args
,
**
kwargs
):
logging
.
warn
(
'%s (from %s) is deprecated and will be removed after %s.
\n
'
'Instructions for updating:
\n
%s'
,
_get_qualified_name
(
func
),
func
.
__module__
,
date
,
instructions
)
return
func
(
*
args
,
**
kwargs
)
new_func
.
__name__
=
func
.
__name__
new_func
.
__doc__
=
_add_deprecation_to_docstring
(
func
.
__doc__
,
date
,
instructions
)
new_func
.
__dict__
.
update
(
func
.
__dict__
)
return
new_func
return
deprecated_wrapper
tensorflow/contrib/learn/python/learn/ops/dnn_ops.py
浏览文件 @
1b65fb67
...
...
@@ -20,6 +20,7 @@ from __future__ import division
from
__future__
import
print_function
from
tensorflow.contrib
import
layers
from
tensorflow.contrib.framework.python.framework.deprecation
import
deprecated
from
tensorflow.contrib.learn.python.learn.ops
import
dropout_ops
from
tensorflow.python.framework
import
ops
from
tensorflow.python.ops
import
array_ops
as
array_ops_
...
...
@@ -28,6 +29,7 @@ from tensorflow.python.ops import nn
from
tensorflow.python.ops
import
variable_scope
as
vs
@
deprecated
(
'2016-08-01'
,
'Please use tf.contrib.layers.stack instead.'
)
def
dnn
(
tensor_in
,
hidden_units
,
activation
=
nn
.
relu
,
dropout
=
None
):
"""Creates fully connected deep neural network subgraph.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录