2016-06-22 14 views
5

मैं अपने आरएनएन की स्थिति को बचाने के लिए tf.with_dependencies फ़ंक्शन का उपयोग करना चाहता हूं। किसी कारण से मुझे निम्न त्रुटि मिलती है।टेंसरफ्लो में कोई विशेषता नहीं है "with_dependencies"

Traceback (most recent call last): 
    File "/home/chase/workspace/AudioRNN/audiornn.py", line 56, in <module> 
    tf.with_dependencies([expected_output], input_tensor) 
AttributeError: module 'tensorflow' has no attribute 'with_dependencies' 

मेरा बाकी tensorflow कोड ठीक चलाता है। मैं ग्रहण में हूं और मैं Ctrl + tf.with_dependencies पर क्लिक करता हूं, यह मुझे स्रोत कोड पर ले जाता है। मैंने देखा कि इस फ़ाइल में tf.group फ़ंक्शन भी है और मैं इसे ठीक कह सकता हूं। tf.with_dependencies के साथ क्या गलत है? मैं उबंटू 16.04 पर हूं। मैं अजगर 3 और tensorflow का नवीनतम संस्करण का उपयोग कर रहा हूँ।

अनुरोध के अनुसार dir(tf) का एक प्रिंट यहां दिया गया है।

AggregationMethod 
Assert 
AttrValue 
ConfigProto 
DType 
DeviceSpec 
Dimension 
Event 
FIFOQueue 
FixedLenFeature 
FixedLenSequenceFeature 
FixedLengthRecordReader 
GPUOptions 
GRAPH_DEF_VERSION 
GRAPH_DEF_VERSION_MIN_CONSUMER 
GRAPH_DEF_VERSION_MIN_PRODUCER 
Graph 
GraphDef 
GraphKeys 
GraphOptions 
HistogramProto 
IdentityReader 
IndexedSlices 
InteractiveSession 
LogMessage 
NameAttrList 
NoGradient 
NodeDef 
OpError 
Operation 
OptimizerOptions 
PaddingFIFOQueue 
Print 
QUANTIZED_DTYPES 
QueueBase 
RandomShuffleQueue 
ReaderBase 
RegisterGradient 
RegisterShape 
RunMetadata 
RunOptions 
Session 
SessionLog 
SparseTensor 
SparseTensorValue 
Summary 
TFRecordReader 
Tensor 
TensorArray 
TensorShape 
TextLineReader 
VarLenFeature 
Variable 
VariableScope 
WholeFileReader 
__builtins__ 
__cached__ 
__doc__ 
__file__ 
__loader__ 
__name__ 
__package__ 
__path__ 
__spec__ 
__version__ 
abs 
absolute_import 
accumulate_n 
acos 
add 
add_check_numerics_ops 
add_n 
add_to_collection 
all_variables 
app 
arg_max 
arg_min 
argmax 
argmin 
as_dtype 
asin 
assert_equal 
assert_integer 
assert_less 
assert_less_equal 
assert_negative 
assert_non_negative 
assert_non_positive 
assert_positive 
assert_proper_iterable 
assert_rank 
assert_rank_at_least 
assert_type 
assert_variables_initialized 
assign 
assign_add 
assign_sub 
atan 
audio_summary 
batch_cholesky 
batch_cholesky_solve 
batch_fft 
batch_fft2d 
batch_fft3d 
batch_ifft 
batch_ifft2d 
batch_ifft3d 
batch_matmul 
batch_matrix_band_part 
batch_matrix_determinant 
batch_matrix_diag 
batch_matrix_diag_part 
batch_matrix_inverse 
batch_matrix_solve 
batch_matrix_solve_ls 
batch_matrix_triangular_solve 
batch_self_adjoint_eig 
batch_to_space 
bfloat16 
bfloat16_ref 
bitcast 
bool 
bool_ref 
boolean_mask 
bytes 
case 
cast 
ceil 
check_numerics 
cholesky 
cholesky_solve 
clip_by_average_norm 
clip_by_global_norm 
clip_by_norm 
clip_by_value 
compat 
complex 
complex128 
complex128_ref 
complex64 
complex64_ref 
complex_abs 
concat 
cond 
conj 
constant 
constant_initializer 
contrib 
control_dependencies 
convert_to_tensor 
convert_to_tensor_or_indexed_slices 
core 
cos 
count_up_to 
create_partitioned_variables 
cross 
decode_csv 
decode_json_example 
decode_raw 
delete_session_tensor 
depth_to_space 
deserialize_many_sparse 
device 
diag 
diag_part 
digamma 
div 
division 
double 
double_ref 
dynamic_partition 
dynamic_stitch 
edit_distance 
equal 
erf 
erfc 
errors 
exp 
expand_dims 
extract_image_patches 
fft 
fft2d 
fft3d 
fill 
flags 
float16 
float16_ref 
float32 
float32_ref 
float64 
float64_ref 
floor 
floordiv 
foldl 
foldr 
gather 
gather_nd 
get_collection 
get_collection_ref 
get_default_graph 
get_default_session 
get_seed 
get_session_handle 
get_session_tensor 
get_variable 
get_variable_scope 
gfile 
global_norm 
gradients 
greater 
greater_equal 
group 
half 
half_ref 
histogram_fixed_width 
histogram_summary 
identity 
ifft 
ifft2d 
ifft3d 
igamma 
igammac 
imag 
image 
image_summary 
import_graph_def 
initialize_all_tables 
initialize_all_variables 
initialize_local_variables 
initialize_variables 
int16 
int16_ref 
int32 
int32_ref 
int64 
int64_ref 
int8 
int8_ref 
inv 
invert_permutation 
is_finite 
is_inf 
is_nan 
is_non_decreasing 
is_numeric_tensor 
is_strictly_increasing 
is_variable_initialized 
lbeta 
less 
less_equal 
lgamma 
lin_space 
linspace 
list_diff 
listdiff 
load_file_system_library 
load_op_library 
local_variables 
log 
logging 
logical_and 
logical_not 
logical_or 
logical_xor 
make_template 
map_fn 
matching_files 
matmul 
matrix_determinant 
matrix_inverse 
matrix_solve 
matrix_solve_ls 
matrix_triangular_solve 
maximum 
merge_all_summaries 
merge_summary 
meshgrid 
minimum 
mod 
moving_average_variables 
mul 
multinomial 
name_scope 
neg 
nn 
no_op 
no_regularizer 
not_equal 
one_hot 
ones 
ones_initializer 
ones_like 
op_scope 
pack 
pad 
parse_example 
parse_single_example 
parse_single_sequence_example 
placeholder 
placeholder_with_default 
polygamma 
pow 
print_function 
py_func 
python 
python_io 
qint16 
qint16_ref 
qint32 
qint32_ref 
qint8 
qint8_ref 
quint16 
quint16_ref 
quint8 
quint8_ref 
random_crop 
random_gamma 
random_normal 
random_normal_initializer 
random_shuffle 
random_uniform 
random_uniform_initializer 
range 
rank 
read_file 
real 
reduce_all 
reduce_any 
reduce_join 
reduce_max 
reduce_mean 
reduce_min 
reduce_prod 
reduce_sum 
register_tensor_conversion_function 
report_uninitialized_variables 
reset_default_graph 
reshape 
resource_loader 
reverse 
reverse_sequence 
round 
rsqrt 
saturate_cast 
scalar_mul 
scalar_summary 
scan 
scatter_add 
scatter_sub 
scatter_update 
segment_max 
segment_mean 
segment_min 
segment_prod 
segment_sum 
select 
self_adjoint_eig 
serialize_many_sparse 
serialize_sparse 
set_random_seed 
shape 
shape_n 
sigmoid 
sign 
sin 
size 
slice 
space_to_batch 
space_to_depth 
sparse_add 
sparse_concat 
sparse_fill_empty_rows 
sparse_mask 
sparse_matmul 
sparse_merge 
sparse_placeholder 
sparse_reduce_sum 
sparse_reorder 
sparse_reset_shape 
sparse_retain 
sparse_segment_mean 
sparse_segment_mean_grad 
sparse_segment_sqrt_n 
sparse_segment_sqrt_n_grad 
sparse_segment_sum 
sparse_softmax 
sparse_split 
sparse_tensor_dense_matmul 
sparse_tensor_to_dense 
sparse_to_dense 
sparse_to_indicator 
split 
sqrt 
square 
squared_difference 
squeeze 
stop_gradient 
string 
string_ref 
string_to_hash_bucket 
string_to_hash_bucket_fast 
string_to_hash_bucket_strong 
string_to_number 
sub 
sysconfig 
tan 
tanh 
test 
tile 
to_bfloat16 
to_double 
to_float 
to_int32 
to_int64 
trace 
train 
trainable_variables 
transpose 
truediv 
truncated_normal 
truncated_normal_initializer 
tuple 
uint16 
uint16_ref 
uint8 
uint8_ref 
uniform_unit_scaling_initializer 
unique 
unique_with_counts 
unpack 
unsorted_segment_sum 
user_ops 
variable_axis_size_partitioner 
variable_op_scope 
variable_scope 
verify_tensor_all_finite 
where 
while_loop 
zeros 
zeros_initializer 
zeros_like 
zeta 
+0

यह एक विन्यास मुद्दे की तरह लगता है, 'tf.with_dependencies के बाद से () प्रारंभिक रिलीज के बाद से एपीआई में रहा है। क्या मॉड्यूल में क्या है यह देखने के लिए आप अपनी स्क्रिप्ट में 'डीआईआर (टीएफ)' प्रिंट करने का प्रयास कर सकते हैं? – mrry

+0

बस इसे जोड़ा गया। टीएफ – chasep255

+0

में कोई निर्भरता नहीं है भ्रम के लिए खेद है- मुझे गलती हुई थी और स्पष्ट रूप से 'tf .__ all__' लागू करने पर हमें इसे एपीआई से हटा दिया होगा। मैं एक कामकाज के साथ एक जवाब पोस्ट करूंगा। – mrry

उत्तर

5

TensorFlow एपीआई में ऐसी कोई समारोह नहीं है।

with tf.control_dependencies([expected_output]): 
    result = tf.identity(input_tensor) 
+5

'tf.with_dependencies' यहां Tensorflow दस्तावेज़ में है: https://www.tensorflow.org/versions/r0.9/api_docs/python/control_flow_ops.html#Assert। उसके साथ क्या है? –

+2

दस्तावेज़ों में गलती की तरह लगता है ... यह कुछ बिंदु पर एपीआई में था (संभवतः केवल पूर्व-रिलीज, लेकिन मुझे बिल्कुल याद नहीं है)। ये लटकने वाले संदर्भ अब गिट रेपो में तय किए गए हैं, और जल्द ही वेबसाइट पर दिखाई दे सकते हैं। – mrry

1

या कोशिश: इसके बजाय आप इच्छित प्रभाव को प्राप्त करने with tf.control_dependencies(): और tf.identity() उपयोग कर सकते हैं tensorflow.python.ops.control_flow_ops से with_dependencies आयात

संबंधित मुद्दे