Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow has no attribute "with_dependencies"

Tags:

tensorflow

I want to use the tf.with_dependencies function to save the state of my RNNs. For some reason I get the following error.

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'

The rest of my tensorflow code runs fine. I am in eclipse and with I Ctrl+Click on tf.with_dependencies it takes me to the source code. I noticed that the tf.group function is also in this file and I can call it fine. What is wrong with tf.with_dependencies? I am on Ubuntu 16.04. I am using python 3 and the latest version of tensorflow.

Here is a print of dir(tf) as requested.

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
like image 483
chasep255 Avatar asked Jun 22 '16 23:06

chasep255


2 Answers

There is no such function in the TensorFlow API. Instead you can use with tf.control_dependencies(): and tf.identity() to achieve the intended effect:

with tf.control_dependencies([expected_output]):
  result = tf.identity(input_tensor)
like image 150
mrry Avatar answered Oct 17 '22 08:10

mrry


Or try: from tensorflow.python.ops.control_flow_ops import with_dependencies

like image 1
buc030 Avatar answered Oct 17 '22 10:10

buc030