text:
How to remove unwanted warning while using GPU with tensorflow

System information

I am using tensorflow version :
OS Platform and Distribution: Linux64-:
TensorFlow installed from pip version 1.4.1
Python 3.6.3 :: Anaconda custom (64-bit)
Cuda-8.0
GPU model and memory: nVIDIA K20 (Kepler)

Describe the problem
I am using Adam Optimizer with a normal sequential network created via keras using tensorflow as backend.
I get the following logs repeatedly for fitting, and creating the network. I also applied batch-normalization for the Dense Layer
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K20Xm, pci bus id: 0000:84:00.0, compute capability: 3.5
Adam_2/decay: (VariableV2): /job:localhost/replica:0/task:0/device:GPU:0
IsVariableInitialized_14: (IsVariableInitialized): /job:localhost/replica:0/task:0/device:GPU:0
Adam_2/decay/read: (Identity): /job:localhost/replica:0/task:0/device:GPU:0
Adam_2/decay/Assign: (Assign): /job:localhost/replica:0/task:0/device:GPU:0
Adam_2/beta_2: (VariableV2): /job:localhost/replica:0/task:0/device:GPU:0
IsVariableInitialized_13: (IsVariableInitialized): /job:localhost/replica:0/task:0/device:GPU:0
training/Adam/gradients/batch_normalization_3_1/batchnorm/mul_grad/Shape_1: (Const): /job:localhost/replica:0/task:0/device:GPU:0
training/Adam/gradients/batch_normalization_3_1/batchnorm/mul_grad/Shape: (Const): /job:localhost/replica:0/task:0/device:GPU:0
training/Adam/gradients/batch_normalization_3_1/moments/Squeeze_grad/Shape: (Const): /job:localhost/replica:0/task:0/device:GPU:0
training/Adam/gradients/zeros_87/Const: (Const): /job:localhost/replica:0/task:0/device:GPU:0
How to turn off these unwanted logs?
I have already applied the following solution for switching off the warning logs from the tensorflow.
https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information
Source code
from keras.layers.normalization import BatchNormalization
model = Sequential()
model.add(Dense(64, input_dim=14, init='relu'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(Dense(64, init='uniform'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(Dense(1, init='uniform'))
model.add(BatchNormalization())
model.add(Activation('softmax'))
model.compile(loss='binary_crossentropy', optimizer=Adam())
model.fit(X_train, y_train)

Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 143 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 158 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 173 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 188 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 203 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 218 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 233 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @zheng-xq: It has been 248 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @tfboyd: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @tfboyd: It has been 29 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @tfboyd: It has been 44 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @tfboyd: It has been 59 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Nagging Assignee @tfboyd: It has been 74 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Has this been solved?
I have the same issue, I've tried doing
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
but i keep having the prints. My OS is Windows10 and i'm using Cuda-9.0

Has this been solved?
I have the same issue, I've tried doing
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
but i keep having the prints. My OS is Windows10 and i'm using Cuda-9.0

Closing due to staleness. Please check with the latest version of TensorFlow. Feel free to reopen if the issue still persists. Thanks!

authors: JoanaGodinho prithagupta tensorflowbutler ymodak


text:
install  mac os by pip3

Environment info
Operating System:
Mac OS 10.11.1
i try:
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp35-none-any.whl
Logs or other output that would be helpful
(If logs are large, please upload as attachment).
bogon:~ liu$ sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp35-none-any.whl
The directory '/Users/liu/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/liu/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
tensorflow-0.7.1-cp35-none-any.whl is not a supported wheel on this platform.
You are using pip version 7.1.2, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
bogon:~ liu$

There seems to be 2 issues, one is directory permissions, and the other is that the whl file is not compatible on your platform. Do you mind trying the pip install under a virtualenv?
$ virtualenv -p `which python3` py3env
$ source py3env/bin/activate
# No sudo
$ pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp35-none-any.whl

I'm also getting this issue but on Linux. I've tried installing tensorflow both on AWS EC2 and through herokus python buildpack but in both instances got the error tensorflow-0.7.1-cp27-none-linux_x86_64.whl is not a supported wheel on this platform. Was able to get it on the EC2 using this guys conda package but still can't get it on heroku.

What's your python3 version? also try upgrade your pip and setuptool?.
% pip3 install --upgrade pip setuptools

I ended up getting it working on the EC2 using a a conda install and on heroku by switching from python 3.5.1 to 3.4.0

i use python3.4.4 and upgrade pip to the newset,try virtulenviroment. but still not work...

Can you try execute and print python3 with the following command?
import pip; print(pip.pep425tags.get_supported())
Example:

$ python3
Python 3.5.1 (default, Dec  7 2015, 21:59:08)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import pip; print(pip.pep425tags.get_supported())
[('cp35', 'cp35m', 'macosx_10_10_x86_64'), ('cp35', 'cp35m', 'macosx_10_10_intel'), ('cp35', 'cp35m', 'macosx_10_10_fat64'), ('cp35', 'cp35m', 'macosx_10_10_fat32'),.....

As an alternative, I'll suggest that you can download  tensorflow-0.7.1-py3-none-any.whl by via Nightly Build

thx,it finally work successfully!!!
2016-04-01 19:45 GMT+08:00 Cheng-Lung Sung notifications@github.com:

As an alternative, I'll suggest that you can download
tensorflow-0.7.1-py3-none-any.whl by via Nightly Build
http://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_CONTAINER_TYPE=CPU,TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=mac-slave/
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/tensorflow/tensorflow/issues/1674#issuecomment-204360706

I also had this same issue, ...is not a supported wheel on this platform..  when trying to install with python 3.4.3 and pip 8.1
To fix issue:

used pyenv to pull down upgraded to python 3.5.1, switched it to be my global python
Created a virtual env via pyvenv (not virtualenv, but I think this is irrelevant)
Ran  pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp35-none-any.whl

Worked!!!

source: gharchive/issue

authors: Heipiao clsung kennmyers keveman raymondjplante

repo: tensorflow/tensorflow

license_type: permissive

license_source: github-api


text:
Bug: instantiating dynamic_rnn with tf.int32 in input and state raises TypeError

System information

OS Platform: OS X 10.13.3
Custom code
tensorflow version: 1.12.0
python version: 3.6.5

Describe the current behavior
Tensorflow raises a TypeError when creating a dynamic_rnn with tf.int32 type in its input and state. When changing the type to tf.float32 the error is not raised.
Describe the expected behavior
Ideally, a dynamic_rnn should support tf.in32 types. If there's any reason why instantiating a dynamic_rnn with tf.int32 type in its input and state should not be allowed, a custom error should be raised.
Code to reproduce the issue
The code below reproduces the error:
import tensorflow as tf

X = tf.placeholder(tf.int32, [None, 10, 1])
cell = tf.nn.rnn_cell.LSTMCell(1, dtype=tf.int32)
output, state = tf.nn.dynamic_rnn(cell=cell, inputs=X, dtype=tf.int32)

The code below doesn't:

import tensorflow as tf

X = tf.placeholder(tf.float32, [None, 10, 1])
cell = tf.nn.rnn_cell.LSTMCell(1, dtype=tf.float32)
output, state = tf.nn.dynamic_rnn(cell=cell, inputs=X, dtype=tf.float32)

Note the change in dtype.
Other info / logs
TRACEBACK:
TypeError                                 Traceback (most recent call last)
 in ()
2 X = tf.placeholder(tf.int32, [None, 10, 1])
3 cell = tf.nn.rnn_cell.LSTMCell(1, dtype=tf.int32)
----> 4 output, state = tf.nn.dynamic_rnn(cell=cell, inputs=X, dtype=tf.int32)#, initial_state=state)
5
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py in dynamic_rnn(cell, inputs, sequence_length, initial_state, dtype, parallel_iterations, swap_memory, time_major, scope)
662         swap_memory=swap_memory,
663         sequence_length=sequence_length,
--> 664         dtype=dtype)
665
666     # Outputs of _dynamic_rnn_loop are always shaped [time, batch, depth].
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py in _dynamic_rnn_loop(cell, inputs, initial_state, parallel_iterations, swap_memory, sequence_length, dtype)
870       parallel_iterations=parallel_iterations,
871       maximum_iterations=time_steps,
--> 872       swap_memory=swap_memory)
873
874   # Unpack final output if not using output tuples.
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py in while_loop(cond, body, loop_vars, shape_invariants, parallel_iterations, back_prop, swap_memory, name, maximum_iterations, return_same_structure)
3289       ops.add_to_collection(ops.GraphKeys.WHILE_CONTEXT, loop_context)
3290     result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants,
-> 3291                                     return_same_structure)
3292     if maximum_iterations is not None:
3293       return result[1]
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py in BuildLoop(self, pred, body, loop_vars, shape_invariants, return_same_structure)
3002       with ops.get_default_graph()._mutation_lock():  # pylint: disable=protected-access
3003         original_body_result, exit_vars = self._BuildLoop(
-> 3004             pred, body, original_loop_vars, loop_vars, shape_invariants)
3005     finally:
3006       self.Exit()
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py in _BuildLoop(self, pred, body, original_loop_vars, loop_vars, shape_invariants)
2937         flat_sequence=vars_for_body_with_tensor_arrays)
2938     pre_summaries = ops.get_collection(ops.GraphKeys._SUMMARY_COLLECTION)  # pylint: disable=protected-access
-> 2939     body_result = body(*packed_vars_for_body)
2940     post_summaries = ops.get_collection(ops.GraphKeys._SUMMARY_COLLECTION)  # pylint: disable=protected-access
2941     if not nest.is_sequence(body_result):
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py in (i, lv)
3258         cond = lambda i, lv: (  # pylint: disable=g-long-lambda
3259             math_ops.logical_and(i < maximum_iterations, orig_cond(*lv)))
-> 3260         body = lambda i, lv: (i + 1, orig_body(*lv))
3261
3262     if context.executing_eagerly():
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py in _time_step(time, output_ta_t, state)
838           skip_conditionals=True)
839     else:
--> 840       (output, new_state) = call_cell()
841
842     # Keras cells always wrap state as list, even if it's a single tensor.
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py in ()
824     if is_keras_rnn_cell and not nest.is_sequence(state):
825       state = [state]
--> 826     call_cell = lambda: cell(input_t, state)
827
828     if sequence_length is not None:
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py in call(self, inputs, state, scope, *args, **kwargs)
368     # method.  See the class docstring for more details.
369     return base_layer.Layer.call(self, inputs, state, scope=scope,
--> 370                                      *args, **kwargs)
371
372
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/layers/base.py in call(self, inputs, *args, **kwargs)
372
373       # Actually call layer
--> 374       outputs = super(Layer, self).call(inputs, *args, **kwargs)
375
376     if not context.executing_eagerly():
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in call(self, inputs, *args, **kwargs)
755       if not in_deferred_mode:
756         self._in_call = True
--> 757         outputs = self.call(inputs, *args, **kwargs)
758         self._in_call = False
759         if outputs is None:
~/jonassucks3/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py in call(self, inputs, state)
1003            sigmoid(i + self._w_i_diag * c_prev) * self._activation(j))
1004     else:
-> 1005       c = (sigmoid(f + self._forget_bias) * c_prev + sigmoid(i) *
1006            self._activation(j))
1007
TypeError: unsupported operand type(s) for +: 'Tensor' and 'float'

Thanks for the clear repro example. Probably this is a duplicate of #14729

Thanks for the report, I will take a look today or tomorrow.

authors: javiermas qlzh727 ymodak


text:
In a @tf.function, after for i in tf.range(10), i is still undefined

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
Yes
OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
MacOSX 10.13.6
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
No
TensorFlow installed from (source or binary):
Binary
TensorFlow version (use command below):
tf.version.VERSION: 2.0.0-dev20190302
tf.version.GIT_VERSION: v1.12.0-9439-g837e5feed2
Python version:
3.6.8
Bazel version (if compiling from source):
N/A
GCC/Compiler version (if compiling from source):
N/A
CUDA/cuDNN version:
N/A
GPU model and memory:
N/A

Describe the current behavior
When using a for loop in a @tf.function (with autograph), such as for i in tf.range(10), i is undefined after the loop ends, unless it is defined in the global scope, in which case it takes this value.
Describe the expected behavior
I expect the same behavior as in regular Python: i should be the last value that was run in the for loop.
Code to reproduce the issue
import tensorflow as tf

@tf.function
def loop():
    for i in tf.range(10):
        pass
    return i

loop() # NameError: name 'i' is not defined (see full stacktrace below)

If I define i outside of the function, then autograph uses that:
import tensorflow as tf

i = 1234

@tf.function
def loop():
    for i in tf.range(10):
        pass
    return i

print(loop().numpy()) # prints 1234, which is *incorrect*

The correct behavior should be the same as without decorating with @tf.function:
import tensorflow as tf

i = 1234

def loop():
    for i in tf.range(10):
        pass
    return i

print(loop().numpy()) # prints 9, which is correct.

Other info / logs
Here is the stacktrace:
NameError                                 Traceback (most recent call last)
<ipython-input-1-2ae01b93772c> in <module>
      7     return i
      8
----> 9 loop() # NameError: name 'i' is not defined (see full stacktrace below)

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py in __call__(self, *args, **kwds)
    424     # This is the first call of __call__, so we have to initialize.
    425     initializer_map = {}
--> 426     self._initialize(args, kwds, add_initializers_to=initializer_map)
    427     if self._created_variables:
    428       try:

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py in _initialize(self, args, kwds, add_initializers_to)
    368     self._concrete_stateful_fn = (
    369         self._stateful_fn._get_concrete_function_internal_garbage_collected(  # pylint: disable=protected-access
--> 370             *args, **kwds))
    371
    372     def invalid_creator_scope(*unused_args, **unused_kwds):

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/function.py in _get_concrete_function_internal_garbage_collected(self, *args, **kwargs)
   1311     if self._input_signature:
   1312       args, kwargs = None, None
-> 1313     graph_function, _, _ = self._maybe_define_function(args, kwargs)
   1314     return graph_function
   1315

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs)
   1578           or call_context_key not in self._function_cache.missed):
   1579         self._function_cache.missed.add(call_context_key)
-> 1580         graph_function = self._create_graph_function(args, kwargs)
   1581         self._function_cache.primary[cache_key] = graph_function
   1582         return graph_function, args, kwargs

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes)
   1510             arg_names=arg_names,
   1511             override_flat_arg_shapes=override_flat_arg_shapes,
-> 1512             capture_by_value=self._capture_by_value),
   1513         self._function_attributes)
   1514

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)
    692                                           converted_func)
    693
--> 694       func_outputs = python_func(*func_args, **func_kwargs)
    695
    696       # invariant: `func_outputs` contains only Tensors, IndexedSlices,

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py in wrapped_fn(*args, **kwds)
    315         # __wrapped__ allows AutoGraph to swap in a converted function. We give
    316         # the function a weak reference to itself to avoid a reference cycle.
--> 317         return weak_wrapped_fn().__wrapped__(*args, **kwds)
    318     weak_wrapped_fn = weakref.ref(wrapped_fn)
    319

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
    684                   optional_features=autograph_options,
    685                   force_conversion=True,
--> 686               ), args, kwargs)
    687
    688         # Wrapping around a decorator allows checks like tf_inspect.getargspec

~/.virtualenvs/tf2/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py in converted_call(f, owner, options, args, kwargs)
    390     return _call_unconverted(f, args, kwargs)
    391
--> 392   result = converted_f(*effective_args, **kwargs)
    393
    394   # The converted function's closure is simply inserted into the function's

/var/folders/wy/h39t6kb11pnbb0pzhksd_fqh0000gn/T/tmpk_ywisd3.py in tf__loop()
     10   ag__.for_stmt(ag__.converted_call('range', tf, ag__.ConversionOptions(recursive=True, verbose=0, strip_decorators=(tf.function, defun, ag__.convert, ag__.do_not_convert, ag__.converted_call), force_conversion=False, optional_features=(), internal_convert_user_code=True), (10,), {}), None, loop_body, ())
     11   do_return = True
---> 12   retval_ = i
     13   return retval_
     14

NameError: name 'i' is not defined

@mdanatg would you mind triaging?

Thanks for the report! We're working on fixing this issue.

Quick update: we'll definitely fix this for Python control flow, so that it behaves like normal code. For TensorFlow loops, that task will be more challenging and initially we will probably raise an error instead.
Consider for example:
for i in range(0):
  pass
return i  # Runtime error: i is undefined

Because TensorFlow doesn't support the notion of undefined variables, replicating that behavior using tf.while_loop would be a bit trickier, although possible. Strictly speaking, we would need to generate the following code:
iterated = tf.range(0)

def cond(idx, i, i_is_defined):
  return tf.less(idx, iterated.shape[0])

def body(idx, i, i_is_defined):
  i = iterated[idx]
  i_is_defined = True
  return idx + 1, i, i_is_defined

dummy_for_undefined_i = tf.zeros(iterated.shape[1:])  # This value should never be used
_, i_is_defined = tf.while_loop(cond, body, [0, dummy_for_undefined_i, False])
tf.assert(i_is_defined, 'i is undefined')

@brilee FYI

This needs attention. I'm having quite some problems with using tf.function and autograph whose basic features supposedly have been implemented some time ago.

Working on it now!

fixed in https://github.com/tensorflow/tensorflow/commit/d686d910e66392d27a0d67891248fa989b32e782

FYI - The construct
@tf.function
def f():
  for i in tf.range(10):
    pass
  return i

will still raise an exception saying "i must be defined for a tf.while_loop". That's a much lower priority bug but it's on our radar.

authors: ageron allenlavoie brilee caissalover mdanatg


text:
Quantization-aware training Fails

Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: One plus 5
TensorFlow installed from (source or binary): binary
TensorFlow version (use command below): 1.13
Python version:3.6
Bazel version (if compiling from source):bazel-0.24.0-installer-darwin-x86_64
GCC/Compiler version (if compiling from source): NA
CUDA/cuDNN version: NA
GPU model and memory: NA

Describe the current behavior
I am referring to https://github.com/tensorflow/tensorflow/issues/20867. I am currently running Quantization-aware training and I have modified my deeplab->train.py file. When I start training using train.py :

# Copyright 2018 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.
# ==============================================================================
"""Training script for the DeepLab model.

See model.py for more details and usage.
"""

import six
import tensorflow as tf
from tensorflow.python.ops import math_ops
from deeplab import common
from deeplab import model
from deeplab.datasets import data_generator
from deeplab.utils import train_utils

flags = tf.app.flags
FLAGS = flags.FLAGS

# Settings for multi-GPUs/multi-replicas training.

flags.DEFINE_integer('num_clones', 1, 'Number of clones to deploy.')

flags.DEFINE_boolean('clone_on_cpu', False, 'Use CPUs to deploy clones.')

flags.DEFINE_integer('num_replicas', 1, 'Number of worker replicas.')

flags.DEFINE_integer('startup_delay_steps', 15,
                     'Number of training steps between replicas startup.')

flags.DEFINE_integer(
    'num_ps_tasks', 0,
    'The number of parameter servers. If the value is 0, then '
    'the parameters are handled locally by the worker.')

flags.DEFINE_string('master', '', 'BNS name of the tensorflow server')

flags.DEFINE_integer('task', 0, 'The task ID.')

# Settings for logging.

flags.DEFINE_string('train_logdir', None,
                    'Where the checkpoint and logs are stored.')

flags.DEFINE_integer('log_steps', 10,
                     'Display logging information at every log_steps.')

flags.DEFINE_integer('save_interval_secs', 1200,
                     'How often, in seconds, we save the model to disk.')

flags.DEFINE_integer('save_summaries_secs', 600,
                     'How often, in seconds, we compute the summaries.')

flags.DEFINE_boolean(
    'save_summaries_images', False,
    'Save sample inputs, labels, and semantic predictions as '
    'images to summary.')

# Settings for profiling.

flags.DEFINE_string('profile_logdir', None,
                    'Where the profile files are stored.')

# Settings for training strategy.

flags.DEFINE_enum('learning_policy', 'poly', ['poly', 'step'],
                  'Learning rate policy for training.')

# Use 0.007 when training on PASCAL augmented training set, train_aug. When
# fine-tuning on PASCAL trainval set, use learning rate=0.0001.
flags.DEFINE_float('base_learning_rate', .0001,
                   'The base learning rate for model training.')

flags.DEFINE_float('learning_rate_decay_factor', 0.1,
                   'The rate to decay the base learning rate.')

flags.DEFINE_integer('learning_rate_decay_step', 2000,
                     'Decay the base learning rate at a fixed step.')

flags.DEFINE_float('learning_power', 0.9,
                   'The power value used in the poly learning policy.')

flags.DEFINE_integer('training_number_of_steps', 30000,
                     'The number of steps used for training')

flags.DEFINE_float('momentum', 0.9, 'The momentum value to use')

# When fine_tune_batch_norm=True, use at least batch size larger than 12
# (batch size more than 16 is better). Otherwise, one could use smaller batch
# size and set fine_tune_batch_norm=False.
flags.DEFINE_integer('train_batch_size', 8,
                     'The number of images in each batch during training.')

# For weight_decay, use 0.00004 for MobileNet-V2 or Xcpetion model variants.
# Use 0.0001 for ResNet model variants.
flags.DEFINE_float('weight_decay', 0.00004,
                   'The value of the weight decay for training.')

flags.DEFINE_multi_integer('train_crop_size', [513, 513],
                           'Image crop size [height, width] during training.')

flags.DEFINE_float(
    'last_layer_gradient_multiplier', 1.0,
    'The gradient multiplier for last layers, which is used to '
    'boost the gradient of last layers if the value > 1.')

flags.DEFINE_boolean('upsample_logits', True,
                     'Upsample logits during training.')

# Hyper-parameters for NAS training strategy.

flags.DEFINE_float(
    'drop_path_keep_prob', 1.0,
    'Probability to keep each path in the NAS cell when training.')

# Settings for fine-tuning the network.

flags.DEFINE_string('tf_initial_checkpoint', None,
                    'The initial checkpoint in tensorflow format.')

# Set to False if one does not want to re-use the trained classifier weights.
flags.DEFINE_boolean('initialize_last_layer', True,
                     'Initialize the last layer.')

flags.DEFINE_boolean('last_layers_contain_logits_only', False,
                     'Only consider logits as last layers or not.')

flags.DEFINE_integer('slow_start_step', 0,
                     'Training model with small learning rate for few steps.')

flags.DEFINE_float('slow_start_learning_rate', 1e-4,
                   'Learning rate employed during slow start.')

# Set to True if one wants to fine-tune the batch norm parameters in DeepLabv3.
# Set to False and use small batch size to save GPU memory.
flags.DEFINE_boolean('fine_tune_batch_norm', True,
                     'Fine tune the batch norm parameters or not.')

flags.DEFINE_float('min_scale_factor', 0.5,
                   'Mininum scale factor for data augmentation.')

flags.DEFINE_float('max_scale_factor', 2.,
                   'Maximum scale factor for data augmentation.')

flags.DEFINE_float('scale_factor_step_size', 0.25,
                   'Scale factor step size for data augmentation.')

# For `xception_65`, use atrous_rates = [12, 24, 36] if output_stride = 8, or
# rates = [6, 12, 18] if output_stride = 16. For `mobilenet_v2`, use None. Note
# one could use different atrous_rates/output_stride during training/evaluation.
flags.DEFINE_multi_integer('atrous_rates', None,
                           'Atrous rates for atrous spatial pyramid pooling.')

flags.DEFINE_integer('output_stride', 16,
                     'The ratio of input to output spatial resolution.')

# Hard example mining related flags.

flags.DEFINE_integer(
    'hard_example_mining_step', 0,
    'The training step in which exact hard example mining kicks off. Note we '
    'gradually reduce the mining percent to the specified '
    'top_k_percent_pixels. For example, if hard_example_mining_step=100K and '
    'top_k_percent_pixels=0.25, then mining percent will gradually reduce from '
    '100% to 25% until 100K steps after which we only mine top 25% pixels.')

flags.DEFINE_float(
    'top_k_percent_pixels', 1.0,
    'The top k percent pixels (in terms of the loss values) used to compute '
    'loss during training. This is useful for hard pixel mining.')

# Dataset settings.
flags.DEFINE_string('dataset', 'pascal_voc_seg',
                    'Name of the segmentation dataset.')

flags.DEFINE_string('train_split', 'train',
                    'Which split of the dataset to be used for training')

flags.DEFINE_string('dataset_dir', None, 'Where the dataset reside.')

def _build_deeplab(iterator, outputs_to_num_classes, ignore_label):
  """Builds a clone of DeepLab.

  Args:
    iterator: An iterator of type tf.data.Iterator for images and labels.
    outputs_to_num_classes: A map from output type to the number of classes. For
      example, for the task of semantic segmentation with 21 semantic classes,
      we would have outputs_to_num_classes['semantic'] = 21.
    ignore_label: Ignore label.
  """
  samples = iterator.get_next()

  # Add name to input and label nodes so we can add to summary.
  samples[common.IMAGE] = tf.identity(samples[common.IMAGE], name=common.IMAGE)
  samples[common.LABEL] = tf.identity(samples[common.LABEL], name=common.LABEL)

  model_options = common.ModelOptions(
      outputs_to_num_classes=outputs_to_num_classes,
      crop_size=FLAGS.train_crop_size,
      atrous_rates=FLAGS.atrous_rates,
      output_stride=FLAGS.output_stride)

  outputs_to_scales_to_logits = model.multi_scale_logits(
      samples[common.IMAGE],
      model_options=model_options,
      image_pyramid=FLAGS.image_pyramid,
      weight_decay=FLAGS.weight_decay,
      is_training=True,
      fine_tune_batch_norm=FLAGS.fine_tune_batch_norm,
      nas_training_hyper_parameters={
          'drop_path_keep_prob': FLAGS.drop_path_keep_prob,
          'total_training_steps': FLAGS.training_number_of_steps,
      })

  # Add name to graph node so we can add to summary.
  output_type_dict = outputs_to_scales_to_logits[common.OUTPUT_TYPE]
  output_type_dict[model.MERGED_LOGITS_SCOPE] = tf.identity(
      output_type_dict[model.MERGED_LOGITS_SCOPE], name=common.OUTPUT_TYPE)

  for output, num_classes in six.iteritems(outputs_to_num_classes):
    train_utils.add_softmax_cross_entropy_loss_for_each_scale(
        outputs_to_scales_to_logits[output],
        samples[common.LABEL],
        num_classes,
        ignore_label,
        loss_weight=1.0,
        upsample_logits=FLAGS.upsample_logits,
        hard_example_mining_step=FLAGS.hard_example_mining_step,
        top_k_percent_pixels=FLAGS.top_k_percent_pixels,
        scope=output)

    # Log the summary
    _log_summaries(samples[common.IMAGE], samples[common.LABEL], num_classes,
                   output_type_dict[model.MERGED_LOGITS_SCOPE])

def _tower_loss(iterator, num_of_classes, ignore_label, scope, reuse_variable):
  """Calculates the total loss on a single tower running the deeplab model.

  Args:
    iterator: An iterator of type tf.data.Iterator for images and labels.
    num_of_classes: Number of classes for the dataset.
    ignore_label: Ignore label for the dataset.
    scope: Unique prefix string identifying the deeplab tower.
    reuse_variable: If the variable should be reused.

  Returns:
     The total loss for a batch of data.
  """
  with tf.variable_scope(
      tf.get_variable_scope(), reuse=True if reuse_variable else None):
    _build_deeplab(iterator, {common.OUTPUT_TYPE: num_of_classes}, ignore_label)

  losses = tf.losses.get_losses(scope=scope)
  for loss in losses:
    tf.summary.scalar('Losses/%s' % loss.op.name, loss)

  regularization_loss = tf.losses.get_regularization_loss(scope=scope)
  tf.summary.scalar('Losses/%s' % regularization_loss.op.name,
                    regularization_loss)

  total_loss = tf.add_n([tf.add_n(losses), regularization_loss])
  return total_loss

def _average_gradients(tower_grads):
  """Calculates average of gradient for each shared variable across all towers.

  Note that this function provides a synchronization point across all towers.

  Args:
    tower_grads: List of lists of (gradient, variable) tuples. The outer list is
      over individual gradients. The inner list is over the gradient calculation
      for each tower.

  Returns:
     List of pairs of (gradient, variable) where the gradient has been summed
       across all towers.
  """
  average_grads = []
  for grad_and_vars in zip(*tower_grads):
    # Note that each grad_and_vars looks like the following:
    #   ((grad0_gpu0, var0_gpu0), ... , (grad0_gpuN, var0_gpuN))
    grads, variables = zip(*grad_and_vars)
    grad = tf.reduce_mean(tf.stack(grads, axis=0), axis=0)

    # All vars are of the same value, using the first tower here.
    average_grads.append((grad, variables[0]))

  return average_grads

def _log_summaries(input_image, label, num_of_classes, output):
  """Logs the summaries for the model.

  Args:
    input_image: Input image of the model. Its shape is [batch_size, height,
      width, channel].
    label: Label of the image. Its shape is [batch_size, height, width].
    num_of_classes: The number of classes of the dataset.
    output: Output of the model. Its shape is [batch_size, height, width].
  """
  # Add summaries for model variables.
  for model_var in tf.model_variables():
    tf.summary.histogram(model_var.op.name, model_var)

  # Add summaries for images, labels, semantic predictions.
  if FLAGS.save_summaries_images:
    tf.summary.image('samples/%s' % common.IMAGE, input_image)

    # Scale up summary image pixel values for better visualization.
    pixel_scaling = max(1, 255 // num_of_classes)
    summary_label = tf.cast(label * pixel_scaling, tf.uint8)
    tf.summary.image('samples/%s' % common.LABEL, summary_label)

    predictions = tf.expand_dims(tf.argmax(output, 3), -1)
    summary_predictions = tf.cast(predictions * pixel_scaling, tf.uint8)
    tf.summary.image('samples/%s' % common.OUTPUT_TYPE, summary_predictions)

def _train_deeplab_model(iterator, num_of_classes, ignore_label):
  """Trains the deeplab model.

  Args:
    iterator: An iterator of type tf.data.Iterator for images and labels.
    num_of_classes: Number of classes for the dataset.
    ignore_label: Ignore label for the dataset.

  Returns:
    train_tensor: A tensor to update the model variables.
    summary_op: An operation to log the summaries.
  """
  global_step = tf.train.get_or_create_global_step()
  summaries = []

  learning_rate = train_utils.get_model_learning_rate(
      FLAGS.learning_policy, FLAGS.base_learning_rate,
      FLAGS.learning_rate_decay_step, FLAGS.learning_rate_decay_factor,
      FLAGS.training_number_of_steps, FLAGS.learning_power,
      FLAGS.slow_start_step, FLAGS.slow_start_learning_rate)
  summaries.append(tf.summary.scalar('learning_rate', learning_rate))
 # Build forward pass of model.
  loss = tf.losses.get_total_loss()

# Call the training rewrite which rewrites the graph in-place with
# FakeQuantization nodes and folds batchnorm for training. It is
# often needed to fine tune a floating point model for quantization
# with this training tool. When training from scratch, quant_delay
# can be used to activate quantization after training to converge
# with the float graph, effectively fine-tuning the model.
  g = tf.get_default_graph()
  tf.contrib.quantize.create_training_graph(input_graph=g,
                                          quant_delay=2000000)

# Call backward pass optimizer as usual.
  optimizer = tf.train.GradientDescentOptimizer(learning_rate)
  optimizer.minimize(loss)
  #optimizer = tf.train.MomentumOptimizer(learning_rate, FLAGS.momentum)

  tower_grads = []
  tower_summaries = None
  for i in range(FLAGS.num_clones):
    with tf.device('/gpu:%d' % i):
      with tf.name_scope('clone_%d' % i) as scope:
        loss = _tower_loss(
            iterator=iterator,
            num_of_classes=num_of_classes,
            ignore_label=ignore_label,
            scope=scope,
            reuse_variable=(i != 0))
        grads = optimizer.compute_gradients(loss)
        tower_grads.append(grads)

        # Retain the summaries from the first tower.
        if not i:
          tower_summaries = tf.summary.merge_all(scope=scope)

  with tf.device('/cpu:0'):
    grads_and_vars = _average_gradients(tower_grads)
    if tower_summaries is not None:
      summaries.append(tower_summaries)

    # Modify the gradients for biases and last layer variables.
    last_layers = model.get_extra_layer_scopes(
        FLAGS.last_layers_contain_logits_only)
    grad_mult = train_utils.get_model_gradient_multipliers(
        last_layers, FLAGS.last_layer_gradient_multiplier)
    if grad_mult:
      grads_and_vars = tf.contrib.training.multiply_gradients(
          grads_and_vars, grad_mult)

    # Create gradient update op.
    grad_updates = optimizer.apply_gradients(
        grads_and_vars, global_step=global_step)

    # Gather update_ops. These contain, for example,
    # the updates for the batch_norm variables created by model_fn.
    update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
    update_ops.append(grad_updates)
    update_op = tf.group(*update_ops)

    total_loss = tf.losses.get_total_loss(add_regularization_losses=True)

    # Print total loss to the terminal.
    # This implementation is mirrored from tf.slim.summaries.
    should_log = math_ops.equal(math_ops.mod(global_step, FLAGS.log_steps), 0)
    total_loss = tf.cond(
        should_log,
        lambda: tf.Print(total_loss, [total_loss], 'Total loss is :'),
        lambda: total_loss)

    summaries.append(tf.summary.scalar('total_loss', total_loss))

    with tf.control_dependencies([update_op]):
      train_tensor = tf.identity(total_loss, name='train_op')
    summary_op = tf.summary.merge(summaries)

  return train_tensor, summary_op

def main(unused_argv):
  tf.logging.set_verbosity(tf.logging.INFO)

  tf.gfile.MakeDirs(FLAGS.train_logdir)
  tf.logging.info('Training on %s set', FLAGS.train_split)

  graph = tf.Graph()
  with graph.as_default():
    with tf.device(tf.train.replica_device_setter(ps_tasks=FLAGS.num_ps_tasks)):
      assert FLAGS.train_batch_size % FLAGS.num_clones == 0, (
          'Training batch size not divisble by number of clones (GPUs).')
      clone_batch_size = FLAGS.train_batch_size // FLAGS.num_clones

      dataset = data_generator.Dataset(
          dataset_name=FLAGS.dataset,
          split_name=FLAGS.train_split,
          dataset_dir=FLAGS.dataset_dir,
          batch_size=clone_batch_size,
          crop_size=FLAGS.train_crop_size,
          min_resize_value=FLAGS.min_resize_value,
          max_resize_value=FLAGS.max_resize_value,
          resize_factor=FLAGS.resize_factor,
          min_scale_factor=FLAGS.min_scale_factor,
          max_scale_factor=FLAGS.max_scale_factor,
          scale_factor_step_size=FLAGS.scale_factor_step_size,
          model_variant=FLAGS.model_variant,
          num_readers=2,
          is_training=True,
          should_shuffle=True,
          should_repeat=True)

      train_tensor, summary_op = _train_deeplab_model(
          dataset.get_one_shot_iterator(), dataset.num_of_classes,
          dataset.ignore_label)

      # Soft placement allows placing on CPU ops without GPU implementation.
      session_config = tf.ConfigProto(
          allow_soft_placement=True, log_device_placement=False)

      last_layers = model.get_extra_layer_scopes(
          FLAGS.last_layers_contain_logits_only)
      init_fn = None
      if FLAGS.tf_initial_checkpoint:
        init_fn = train_utils.get_model_init_fn(
            FLAGS.train_logdir,
            FLAGS.tf_initial_checkpoint,
            FLAGS.initialize_last_layer,
            last_layers,
            ignore_missing_vars=True)

      scaffold = tf.train.Scaffold(
          init_fn=init_fn,
          summary_op=summary_op,
      )

      stop_hook = tf.train.StopAtStepHook(FLAGS.training_number_of_steps)

      profile_dir = FLAGS.profile_logdir
      if profile_dir is not None:
        tf.gfile.MakeDirs(profile_dir)

      with tf.contrib.tfprof.ProfileContext(
          enabled=profile_dir is not None, profile_dir=profile_dir):
        with tf.train.MonitoredTrainingSession(
            master=FLAGS.master,
            is_chief=(FLAGS.task == 0),
            config=session_config,
            scaffold=scaffold,
            checkpoint_dir=FLAGS.train_logdir,
            summary_dir=FLAGS.train_logdir,
            log_step_count_steps=FLAGS.log_steps,
            save_summaries_steps=FLAGS.save_summaries_secs,
            save_checkpoint_secs=FLAGS.save_interval_secs,
            hooks=[stop_hook]) as sess:
          while not sess.should_stop():
            sess.run([train_tensor])

if __name__ == '__main__':
  flags.mark_flag_as_required('train_logdir')
  flags.mark_flag_as_required('dataset_dir')
  tf.app.run()

**Describe the expected behavior**

**Code to reproduce the issue**
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

**Other info / logs**
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

I get the following error:

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:

https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

INFO:tensorflow:Training on train set
WARNING:tensorflow:From /home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py:423: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/ubuntu/ajinkya/models/research/deeplab/core/preprocess_utils.py:203: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Traceback (most recent call last):
File "deeplab/train2.py", line 516, in
tf.app.run()
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "deeplab/train2.py", line 468, in main
dataset.ignore_label)
File "deeplab/train2.py", line 348, in _train_deeplab_model
loss = tf.losses.get_total_loss()
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/ops/losses/util.py", line 112, in get_total_loss
return math_ops.add_n(losses, name=name)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 2658, in add_n
raise ValueError("inputs must be a list of at least one"
ValueError: inputs must be a list of at least oneTensor/IndexedSlices with the same dtype and shape

How do I resolve this error? Its extremely tough to debug whats happening here

@ajinkya933 This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there.If you think we've misinterpreted a bug, please comment again with a clear explanation, as well as all of the information requested in the issue template. Thanks!

@ajinkya933 did you solved the issue ??

authors: ajinkya933 essalahsouad muddham


text:
Return better error message when using RefVariables with v2 control flow

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):yes
OS Platform and Distribution (e.g., Linux Ubuntu 16.04):archlinux
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:n/a
TensorFlow installed from (source or binary):binary
TensorFlow version (use command below):v1.12.0-12395-g32b84a4 1.14.1-dev20190412  (this is the nightly at 20190412).
Python version:3.7
Bazel version (if compiling from source):n/a
GCC/Compiler version (if compiling from source):n/a
CUDA/cuDNN version:n/a
GPU model and memory:n/a

The following code:
import os
os.environ['TF_ENABLE_COND_V2'] = '1'
import tensorflow as tf

a = tf.get_variable("x", dtype=tf.float32, shape=[3])
loss = tf.reduce_sum(a)
opt = tf.train.GradientDescentOptimizer(0.1)
def f():
    train_op = opt.minimize(loss)
    return train_op
op = tf.cond(tf.greater(a[0], 0), f, tf.no_op)
print(op)

throws:
WARNING: Logging before flag parsing goes to stderr.
W0506 12:29:26.078263 140364116391744 deprecation.py:506] From /home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/ops/init_ops.py:1257: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
Tensor("x/Initializer/random_uniform/max:0", shape=(), dtype=float32) Tensor("x/Initializer/random_uniform/min:0", shape=(), dtype=float32)
Tensor("x/Initializer/random_uniform/RandomUniform:0", shape=(3,), dtype=float32) Tensor("x/Initializer/random_uniform/sub:0", shape=(), dtype=float32)
Traceback (most recent call last):
  File "a.py", line 20, in <module>
    op = tf.cond(tf.greater(a[0], 0), f, tf.no_op)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1921, in cond
    return cond_v2.cond_v2(pred, true_fn, false_fn, name)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/ops/cond_v2.py", line 74, in cond_v2
    op_return_value=pred)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 710, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "a.py", line 16, in f
    train_op = opt.minimize(loss)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/training/optimizer.py", line 412, in minimize
    name=name)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/training/optimizer.py", line 594, in apply_gradients
    update_ops.append(processor.update_op(self, grad))
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/training/optimizer.py", line 118, in update_op
    update_op = optimizer._apply_dense(g, self._v)  # pylint: disable=protected-access
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/training/gradient_descent.py", line 60, in _apply_dense
    use_locking=self._use_locking).op
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/training/gen_training_ops.py", line 639, in apply_gradient_descent
    use_locking=use_locking, name=name)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
    op_def=op_def)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 461, in create_op
    compute_device=compute_device)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3579, in create_op
    op_def=op_def)
  File "/home/XXX/environments/tf1-nightly/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1969, in __init__
    input_types))
TypeError: In op 'GradientDescent/update_x/ApplyGradientDescent', input types ([tf.float32, tf.float32, tf.float32]) are not compatible with expected types ([tf.float32_ref, tf.float32, tf.float32])

But it works without COND_V2. Similar to #24517.

Could you try using tf.enable_resource_variables() or tf.get_variable("x", dtype=tf.float32, shape=[3], use_resource=True).
v2 control flow does not support RefVariables.

Thanks! This does fix the issue. Perhaps this behavior should trigger a more clear error message?

Yep, that would be useful. Let me look into that. Thanks!

@ppwwyyxx Is this still an issue for you? When I ran your code, the error message was clear as shown below. Please check the gist here. Thanks!
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-5216065f60d8> in <module>()
      9     train_op = opt.minimize(loss)
     10     return train_op
---> 11 op = tf.cond(tf.greater(a[0], 0), f, tf.no_op)
     12 print(op)

13 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/framework/ops.py in __init__(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def)
   1724         raise TypeError("In op '%s', input types (%s) are not compatible "
   1725                         "with expected types (%s)" %
-> 1726                         (node_def.name, [i.dtype for i in inputs], input_types))
   1727
   1728     # Build the list of control inputs.

TypeError: In op 'GradientDescent/update_x/ApplyGradientDescent', input types ([tf.float32, tf.float32, tf.float32]) are not compatible with expected types ([tf.float32_ref, tf.float32, tf.float32])

The error was already resolved by @saxenasaurabh suggestion. Thanks!

Hi @ppwwyyxx!  I have edited code and  issue is not replicating after multiple use . please find GIST for reference.

Thanks! It seems it was fixed.

authors: jvishnuvardhan mohantym ppwwyyxx saxenasaurabh


text:
Masking in BERT

In the original paper of BERT it is said:

Note that the purpose of the masking strategies is to reduce the mismatch between pre-training and fine-tuning, as the [MASK] symbol never appears during the fine-tuning stage.

Let's consider a sentence "I am a Liverpool fan" which with 40% masking will be transformed into "I [MASK] a [MASK] fan". When predicting the first [MASK], will it be predicted by a phrase "I [MASK] a fan", excluding the second [MASK] or "I [MASK] a [MASK] fan", by a full sentence?
And what is the purpose of replacing 10% of masked tokens with themselves? Does it mean they will not be predicted? Or we will predict them, having themselves in the context (like predicting the first [MASK] by "I am a [MASK] fan"?
Will be very grateful for any help!

Hi,
I will try to answer your questions. Keep in mind, however that a) my knowledge of BERT only comes from the same paper you read (plus the associated source code and my personal experience re-implementing it for TF 2.0) and b) other design choices could be achieved through an alternative implementation.
That being said:

When predicting the first [MASK], will it be predicted by a phrase "I [MASK] a fan", excluding the second [MASK] or "I [MASK] a [MASK] fan", by a full sentence?

Since the training is conducted on a single forward-pass, the prediction of the first masked token will be based on the encoding of the sentence with both masked tokens. In other words, the sentence "I [MASK] a [MASK] fan" will be fed to the network, embedded, processed by the stack of Transformer encoder blocks, and in the end produce a matrix of shape (n_tokens, model_dim). Then, the masked-tokens-prediction pre-training output layer will further process this matrix and produce predicted tokens probability distributions for each and every tokens marked as masked (both the actual [MASK] ones, and those randomly shifted or not shifted at all yet set to be predicted).

And what is the purpose of replacing 10% of masked tokens with themselves? Does it mean they will not be predicted?

To start with the practical point : the masked tokens replaced with themselves are indeed predicted (and made part of the MLM loss). In other words, what happens is that the MLM loss is based both on the ability of the model to a) predict masked tokens based on context, b) rebuild input non-masked tokens based on their encoding (the case you are asking about), and c) put such tokens in doubt based on their context (the case of tokens replaced by random ones).
This point is arguable, but the idea is that we want to ensure, at the same time, that the encoding retains information on the tokens (and does not just focus on [MASK] ones) - this is the "I can predict a token identical to the input" part - AND incorporates contextual elements - this is the "I can predict the right token instead of the random input one" part. In a sense, you would hope that the model is both able to trust and doubt the input information, and produce encodings of non-masked tokens that retain and embed the valuable information needed for downward tasks (including tasks that would not imply any masked tokens).
I hope this is somehow clearer than the few lines in the paper and can help you! To be honest I struggled a lot with understanding the rationale behind the design (independently from the fact that it is relatively easy to implement).

@pandrey-fr geniously! Thanks a lot, the whole picture has become apparent to me :)

@Aktsvigun That is nice to read! You are welcome :)

authors: Aktsvigun pandrey-fr


text:
Entity <function Function._initialize_uninitialized_variables..initialize_variables at 0x7fa9a442b440> could not be transformed and will be executed

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
OS Platform and Distribution: Ubuntu 18.06
TensorFlow installed from (source or binary):
TensorFlow version (use command below): 2.0.0
Python version: 3.7.4
-using spyder3 ide in anaconda
CUDA/cuDNN version: None

Describe the current behavior
getting this error and the training accuracy doesnt improve
WARNING:tensorflow:Entity <function Function._initialize_uninitialized_variables..initialize_variables at 0x7fa9a442b440> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause:
WARNING: Entity <function Function._initialize_uninitialized_variables..initialize_variables at 0x7fa9a442b440> could not be transformed and will be executed as-is. Please report this to the AutoGraph team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause:
Describe the expected behavior
well, increasing ccuracy and no error basically
Code to reproduce the issue
from tensorflow.keras.models import Sequential
from tensorflow.keras import layers
import numpy as np
y_train = np.random.rand(1)
epochs = 1
x_train = np.random.rand(1,20,16)
model = Sequential()
model.add(layers.LSTM(activation='sigmoid',units = 3,batch_input_shape = (1,20,16)))
model.add(layers.Dense(2, activation='softmax'))
model.compile(loss='sparse_categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.summary()
history = model.fit(x_train, y_train, batch_size=1, epochs=epochs)
this reproduces the error in my usecase
edit: using the solution proposed in
https://github.com/tensorflow/tensorflow/issues/32377
did not work for me ( Requirement already satisfied: gast==0.2.2 )

@PedroDKE
I tried reproducing the issue with TF 2.0 using colab. However i am not seeing any error message. Please, help me in reproducing the issue.Please, find the gist here. Thanks!

wasn't able to reproduce it there either, i tried to reinstall tensorflow but it didtn help either.
here is the error with verbosity set to 10:
INFO:tensorflow:Converted call: <function TensorLikeDataAdapter.init..permutation at 0x7f05a833dcb0>
args: (<tf.Tensor 'args_0:0' shape=() dtype=int64>,)
kwargs: {}
INFO:tensorflow:Whitelisted: <function TensorLikeDataAdapter.init..permutation at 0x7f05a833dcb0>: DoNotConvert rule for tensorflow
INFO:tensorflow:Converted call: <function TensorLikeDataAdapter.init..slice_batch_indices at 0x7f062b289dd0>
args: (<tf.Tensor 'args_0:0' shape=(1,) dtype=int64>,)
kwargs: {}
INFO:tensorflow:Whitelisted: <function TensorLikeDataAdapter.init..slice_batch_indices at 0x7f062b289dd0>: DoNotConvert rule for tensorflow
INFO:tensorflow:Converted call: <function TensorLikeDataAdapter.init..grab_batch at 0x7f050ac61200>
args: (<tf.Tensor 'args_0:0' shape=(1,) dtype=int64>, (<tf.Tensor 'args_1:0' shape=(1, 20, 16) dtype=float64>, <tf.Tensor 'args_2:0' shape=(1, 1) dtype=float64>))
kwargs: {}
INFO:tensorflow:Whitelisted: <function TensorLikeDataAdapter.init..grab_batch at 0x7f050ac61200>: DoNotConvert rule for tensorflow
the error occurs when i try to fit the model

@PedroDKE I tried my laptop (local) and colab and could not reproduce the issue. Can you please share a gist which is throwing the error. Thanks!
Please close the issue if this was already resolved. Thanks!

I think this issue was resolved as I could not reproduce the issue in my local as well as colab. I am closing this issue but please feel free to reopen if the issue persists again. Thanks!

Hi, I have the same problem.

authors: PedroDKE SadakVali jvishnuvardhan ravikyram


text:
Can't open the camera/webcam due to a tensorflow installation problem.

Hello, i have some problems with the installation of tensorflow and the opening of the webcam. Now i am nowhere near experienced with tensorflow, let alone the anaconda prompt menu. I hope you guys could provide me with some help. Thank you in advanced.
(tfpose) C:\Users\gebruiker\Desktop\tf-pose-estimation>python run_webcam.py --model=mobilenet_thin --resize=432x368 --camera=0
Traceback (most recent call last):
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Kan opgegeven module niet vinden.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_webcam.py", line 8, in
from tf_pose.estimator import TfPoseEstimator
File "C:\Users\gebruiker\Desktop\tf-pose-estimation\tf_pose_init_.py", line 5, in
from tf_pose.runner import infer, Estimator, get_estimator
File "C:\Users\gebruiker\Desktop\tf-pose-estimation\tf_pose\runner.py", line 7, in
from tf_pose import common
File "C:\Users\gebruiker\Desktop\tf-pose-estimation\tf_pose\common.py", line 3, in
import tensorflow as tf
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_init_.py", line 101, in
from tensorflow_core import *
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core_init_.py", line 40, in
from tensorflow.python.tools import module_util as module_util
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_init.py", line 50, in getattr
module = self.load()
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_init.py", line 44, in _load
module = importlib.import_module(self.name)
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\importlib_init.py", line 126, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python_init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\gebruiker\Anaconda3\envs\tfpose\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Kan opgegeven module niet vinden.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

@Zayr0,
Could you please check this comment on a similar issue and let us know if it works. Thanks!

@Zayr0,
Any updates regarding this issue? Thanks!

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!


text:
Unable to access files on S3 with tf.io.gfile.GFile

Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template
System information

Have I written custom code (as opposed to using a stock
example script provided in TensorFlow): yes
OS Platform and Distribution (e.g.,
Linux Ubuntu 16.04): MacOS Mojave
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if
the issue happens on mobile device:
TensorFlow installed from (source or
binary): - TensorFlow version (use command below): 2.0.0
Python version: - Bazel
version (if compiling from source):
GCC/Compiler version (if compiling from
source):
CUDA/cuDNN version: - GPU model and memory:

You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with: 1. TF 1.0: python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)" 2. TF 2.0: python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
Describe the current behavior
Executing the following code:
with tf.io.gfile.GFile("s3://path/to/my/file", mode="r") as f:
    data = f.read()

results in the following error message:
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 124, in read
    length = self.size() - self.tell()
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 102, in size
    return stat(self.__name).length
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 727, in stat
    return stat_v2(filename)
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 744, in stat_v2
    pywrap_tensorflow.Stat(compat.as_bytes(path), file_statistics)
tensorflow.python.framework.errors_impl.NotFoundError: Object s3://[REDACTED]/train.txt does not exist

Describe the expected behavior
The contents of the file should be written to variable data
Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/Jupyter/any notebook.
This points to a public s3 file, but still fails:
https://colab.research.google.com/drive/1VSlfzRPdFNSGGI8wd6RdhH9uFj7fkaFG
Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.
2020-03-30 23:22:36.465054: I tensorflow/core/platform/s3/aws_logging.cc:54] Initializing config loader against fileName /Users/neelabh//.aws/config and using profilePrefix = 1
2020-03-30 23:22:36.465103: I tensorflow/core/platform/s3/aws_logging.cc:54] Initializing config loader against fileName /Users/neelabh//.aws/credentials and using profilePrefix = 0
2020-03-30 23:22:36.465129: I tensorflow/core/platform/s3/aws_logging.cc:54] Setting provider to read credentials from /Users/neelabh//.aws/credentials for credentials file and /Users/neelabh//.aws/config for the config file , for use with profile default
2020-03-30 23:22:36.465207: I tensorflow/core/platform/s3/aws_logging.cc:54] Creating AWSHttpResourceClient with max connections2 and scheme http
2020-03-30 23:22:36.465336: I tensorflow/core/platform/s3/aws_logging.cc:54] Initializing CurlHandleContainer with size 2
2020-03-30 23:22:36.465391: I tensorflow/core/platform/s3/aws_logging.cc:54] Creating Instance with default EC2MetadataClient and refresh rate 300000
2020-03-30 23:22:36.465427: I tensorflow/core/platform/s3/aws_logging.cc:54] Added EC2 metadata service credentials provider to the provider chain.
2020-03-30 23:22:36.465682: I tensorflow/core/platform/s3/aws_logging.cc:54] Successfully reloaded configuration.
2020-03-30 23:22:36.465889: I tensorflow/core/platform/s3/aws_logging.cc:54] Initializing CurlHandleContainer with size 25
2020-03-30 23:22:36.466559: I tensorflow/core/platform/s3/aws_logging.cc:54] Pool grown by 2
2020-03-30 23:22:36.466586: I tensorflow/core/platform/s3/aws_logging.cc:54] Connection has been released. Continuing.
2020-03-30 23:22:37.536377: E tensorflow/core/platform/s3/aws_logging.cc:60] HTTP response code: 301
Exception name:
Error message: No response body.
7 response headers:
content-type : application/xml
date : Mon, 30 Mar 2020 17:52:37 GMT
server : AmazonS3
transfer-encoding : chunked
x-amz-bucket-region : eu-north-1
x-amz-id-2 : 021phnKX0e6e9R+N9sMrXZHViGoHdzJrTT5rnyHyWsP8d9ErkPMZT02RbTZcjVeCVrI/3hDkWk8=
x-amz-request-id : 7DAC97A633CA370B
2020-03-30 23:22:37.536443: W tensorflow/core/platform/s3/aws_logging.cc:57] If the signature check failed. This could be because of a time skew. Attempting to adjust the signer.
2020-03-30 23:22:37.536681: I tensorflow/core/platform/s3/aws_logging.cc:54] Connection has been released. Continuing.
2020-03-30 23:22:37.818954: W tensorflow/core/platform/s3/aws_logging.cc:57] Encountered Unknown AWSError 'PermanentRedirect': The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
2020-03-30 23:22:37.819073: E tensorflow/core/platform/s3/aws_logging.cc:60] HTTP response code: 301
Exception name: PermanentRedirect
Error message: Unable to parse ExceptionName: PermanentRedirect Message: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
7 response headers:
content-type : application/xml
date : Mon, 30 Mar 2020 17:52:37 GMT
server : AmazonS3
transfer-encoding : chunked
x-amz-bucket-region : eu-north-1
x-amz-id-2 : ob9TL15Q4Y7/idUzUTWvurB3Z4nxfVYRV2V+9ly88HrVGuHytuZA1U02rhcL0vFUpv83vUxeO9o=
x-amz-request-id : 51E3695245C81463
2020-03-30 23:22:37.819138: W tensorflow/core/platform/s3/aws_logging.cc:57] If the signature check failed. This could be because of a time skew. Attempting to adjust the signer.
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 124, in read
    length = self.size() - self.tell()
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 102, in size
    return stat(self.__name).length
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 727, in stat
    return stat_v2(filename)
  File "/Users/neelabh/opt/anaconda3/envs/tftrt/lib/python3.6/site-packages/tensorflow_core/python/lib/io/file_io.py", line 744, in stat_v2
    pywrap_tensorflow.Stat(compat.as_bytes(path), file_statistics)
tensorflow.python.framework.errors_impl.NotFoundError: Object s3://[REDACTED]/train.txt does not exist

There seems to be a failure before
Exception name: PermanentRedirect
Error message: Unable to parse ExceptionName: PermanentRedirect Message: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

Can you also try with TF 2.1? tf-nightly? To bisect where the error comes from.

Here is what I did:
I ran the following code in a tensorflow/tensorflow:nightly container. TF version was 2.2.0-dev20200402
tf.io.gfile.stat("s3://neelabh-test-public-bucket/train.txt")
`
``

This produced the following error:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/lib/io/file_io.py", line 761, in stat_v2
return _pywrap_file_io.Stat(path)
tensorflow.python.framework.errors_impl.NotFoundError: Object s3://neelabh-test-public-bucket/train.txt does not exist

Now, when I install `boto3` in the same container and use `s3.Object().get()` I am able to download the file.  Also works with wget and the HTTP link to the file.

@nihil0
Is this still an issue?.
Please close this thread if the issue was resolved. Thanks!

Same problem here. Both these API calls (tf.io.gfile.stat or file_io.stat) fail with NotFoundError: Object s3:// <bucket_name>/<path/to/file> does not exist. But if I use boto3 I can download the files without any issue.
# Alternative to reproduce the error
from tensorflow.python.lib.io import file_io
print(file_io.stat('s3://<bucket_name>/<path/to/file>'))

Any news on this? I'm running into a similar issue with tf 2.2 and s3 on ec2.

I'm investigating this and similar issues

For my part it was an SSL problem whenever  I ran TensorFlow on an ec2 instance (curl 77 errors in the logs), I temporarily fixed it by setting S3_VERIFY_SSL=0.

I fixed this issue by adding AWS_REGION and S3_ENDPOINT environment variables. For example:
import os
os.environ['AWS_REGION'] = 'us-west-1'
os.environ['S3_ENDPOINT'] = 'https://s3-us-west-1.amazonaws.com'

@nihil0
Is this still an issue, can you please check on nightly and move this to closed status if resolved.

hi @Saduf2019 do you mind referencing the commit that is meant to fix this?

I have tested on the nightly build, and this problem still persists. The solution of @Abhipray does work: However I'd like to note that

download performance is really poor (100mb files takes over a minute on a connection that should be 10x faster)
no progress bar works with this

For my part it was an SSL problem whenever I ran TensorFlow on an ec2 instance (curl 77 errors in the logs), I temporarily fixed it by setting S3_VERIFY_SSL=0.

Not fixed in my case.
_tensorflow.python.framework.errors_impl.UnknownError: {{function_node wrapped__ReadFile_device/job:localhost/replica:0/task:0/device:CPU:0}} : curlCode: 77, Problem with the SSL CA cert (path? access rights?) [Op:ReadFile]

I am also getting curlCode: 77, Problem with the SSL CA cert (path? access rights?)


text:
opcode 'SUB' version '3' in tfllite_runtime on Windows

System information

Ubuntu 18.04, Nvidia driver 430.4, CUDA 10.1
tf-nightly: 2.4.0-dev20201022, and
tflite_runtime: 2.1.0.post1

Converted keras-model with tf-nightly. This seems to be incompatible with tflite_runtime.
Inference test script:
import numpy as np
import tensorflow as tf
from tflite_runtime.interpreter import Interpreter

# interpreter = tf.lite.Interpreter(model_path="<path_to_wts_file>.tflite")
interpreter = Interpreter(model_path="<path_to_wts_file>.tflite")

input_details = interpreter.get_input_details()

interpreter.resize_tensor_input(input_details[0]['index'], (1, 64, 64, 64, 1))
input_details = interpreter.get_input_details()

interpreter.allocate_tensors()

input_shape = input_details[0]['shape']
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)

interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()

output_details = interpreter.get_output_details()
output_data = interpreter.get_tensor(output_details[0]['index'])

The above works fine when using tf-nightly with:
import tensorflow as tf
interpreter = tf.lite.Interpreter(model_path="<path_to_wts_file>.tflite")

When trying to execute the same with tflite_runtime, it fails to load the model:
from tflite_runtime.interpreter import Interpreter
interpreter = Interpreter(model_path="<path_to_wts_file>.tflite")

Error:
Traceback (most recent call last):
  File "tfliteTest.py", line 13, in <module>
    interpreter = Interpreter(model_path="_<path_to_wts_file>_.tflite")
  File "/home/venv/lib/python3.6/site-packages/tflite_runtime/interpreter.py", line 204, in __init__
    model_path, self._custom_op_registerers))
ValueError: Didn't find op for builtin opcode 'SUB' version '3'
Registration failed.

Is there a nightly build of tflite_runtime?

You are required to use TF Lite runtime that supports Select TF Ops.
You can try updating build.gradle dependencies with
dependencies {     implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'     // This dependency adds the necessary TF op support.     implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly' }
See https://www.tensorflow.org/lite/guide/ops_select#run_inference

This option isn't applicable for the  TensorFlow Lite Interpreter pip package version, right? Which version of TF Lite Runtime supports Select TF Ops ?

when i run this command :
CUSTOM_BAZEL_FLAGS=--define=tflite_pip_with_flex=true tensorflow/lite/tools/pip_package/build_pip_package_with_bazel.sh windows
there is an error:
ERROR: C:/porsapp/tensorflow/tensorflow/tensorflow/core/common_runtime/BUILD:1651:1: Illegal ambiguous match on configurable attribute "deps" in //tensorflow/core/common_runtime:core_cpu_internal:
//tensorflow:windows
//tensorflow:no_gcp_support
Multiple matches are not allowed unless one is unambiguously more specialized.
ERROR: Analysis of target '//tensorflow/lite/python/interpreter_wrapper:_pywrap_tensorflow_interpreter_wrapper' failed; build aborted:

but when i run this:
tensorflow/lite/tools/pip_package/build_pip_package_with_bazel.sh
there is no error.
I've checked out Tensorflow r.2.4. Do you know what the problem is?
@nfisdnf986

I finally build tflite_runtime successfully by removing --config=noaws --config=nogcp --config=nohdfs --config=nonccl options from build_pip_package_with_bazel.sh. The result file is about 26MB but still I got this error:
RuntimeError: Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference.Node number 0 (FlexFusedBatchNormV3) failed to prepare.
Node number 1 (IF) failed to prepare.

I think 'CUSTOM_BAZEL_FLAGS=--define=tflite_pip_with_flex=true' does not work. Because when I build the original tensorflow package and use tensorflow.lite.python.interpreter there is no error.

This is expected. The newer version of the TFLite converter assumes that the model will be used at the same version or the future version. So, at least, you need to use the TF 2.4.0 runtime for your model.

@terryheo could you take a look at this issue?  It is related to build TFLite + Flex runtime at head.

Verified the issue. Working on making a fix.

Sorry about the delayed reply. @pourfard Did the above fix work for you?
@terryheo Thanks for adding that change. I haven't been able to build master branch on Windows, r.2.3 and r2.4 build fine.
Any suggestions for the following error?
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\complex(354): error C2039: 'copysign': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\complex(354): error C3861: 'copysign': identifier not found
Target //tensorflow/tools/pip_package:build_pip_package failed to build

It did not work again:
1- I clone tensorflow repository
2- I run python ./configure.py
3- I run CUSTOM_BAZEL_FLAGS="--define=tflite_pip_with_flex=true" tensorflow/lite/tools/pip_package/build_pip_package_with_bazel.sh windows
*- here is the generated whl file ( It is about 26MB which I think it means it is compiled with FlexDelegate, without it, the wheel file is about 1-2MB)
4- I run pip3.6.exe install .\tflite_runtime-2.5.0-cp36-cp36m-win_amd64.whl
5- I got the same error:
RuntimeError: Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference.Node number 0 (FlexFusedBatchNormV3) failed to prepare.
Node number 1 (IF) failed to prepare.

@terryheo

@nfisdnf986  Yes, it works now,
Thanks a lot, @terryheo

Thank you for the wheel @pourfard. When I try to build with the same command build_pip_package_with_bazel.sh windows, it starts the script in MSYS and gets stuck at setup_with_bazel.py. Did you make any changes other than the --config ones mentioned about to the shell script?
INFO: Found 1 target...
INFO: Deleting stale sandbox base C:/users//_bazel_/hya7usi5/sandbox
[4 / 231] [Prepa] BazelWorkspaceStatusAction stable-status.txt
Target //tensorflow/lite/python/interpreter_wrapper:_pywrap_tensorflow_interpreter_wrapper up-to-date (nothing to build)
INFO: Elapsed time: 11.714s, Critical Path: 0.81s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
+ cp /c/Users//Desktop/temp/build-from-src/tensorflow/tensorflow/lite/tools/pip_package/../../../../bazel-bin/tensorflow/lite/python/interpreter_wrapper/_pywrap_tensorflow_interpreter_wrapper.pyd /c/Users//Desktop/temp/build-from-src/tensorflow/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/tflite_runtime
+ chmod u+w /c/Users//Desktop/temp/build-from-src/tensorflow/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/tflite_runtime/_pywrap_tensorflow_interpreter_wrapper.pyd
+ cd /c/Users//Desktop/temp/build-from-src/tensorflow/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3
+ case "${TENSORFLOW_TARGET}" in
+ [[ -n windows ]]
+ [[ -n '' ]]
+ python3 setup_with_bazel.py bdist bdist_wheel

Sorry about the delayed reply. @pourfard Did the above fix work for you?
@terryheo Thanks for adding that change. I haven't been able to build master branch on Windows, r.2.3 and r2.4 build fine.
Any suggestions for the following error?

ERROR: C:/users//desktop/build-from-src/tensorflow/tensorflow/python/BUILD:5259:1: C++ compilation of rule '//tensorflow/python:_tf_stack.so' failed (Exit 2): cl.exe failed: error executing command
  cd C:/users//_bazel_/poa7uci7/execroot/org_tensorflow
...
...
...
cl : Command line warning D9035 : option 'experimental:preprocessor' has been deprecated and will be removed in a future release
cl : Command line warning D9036 : use 'Zc:preprocessor' instead of 'experimental:preprocessor'
cl : Command line warning D9002 : ignoring unknown option '-fno-strict-aliasing'
cl : Command line warning D9002 : ignoring unknown option '-fexceptions'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\complex(354): error C2039: 'copysign': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\complex(354): error C3861: 'copysign': identifier not found
Target //tensorflow/tools/pip_package:build_pip_package failed to build

Having the same issue trying to build tensorflow from master on windows. The problem seems to be about  library, but I don't understand what's wrong. I have exactly the same error with the same version of MSVC.

Sorry about the delayed reply. @pourfard Did the above fix work for you?
@terryheo Thanks for adding that change. I haven't been able to build master branch on Windows, r.2.3 and r2.4 build fine.
Any suggestions for the following error?

ERROR: C:/users//desktop/build-from-src/tensorflow/tensorflow/python/BUILD:5259:1: C++ compilation of rule '//tensorflow/python:_tf_stack.so' failed (Exit 2): cl.exe failed: error executing command
  cd C:/users//_bazel_/poa7uci7/execroot/org_tensorflow
...
...
...
cl : Command line warning D9035 : option 'experimental:preprocessor' has been deprecated and will be removed in a future release
cl : Command line warning D9036 : use 'Zc:preprocessor' instead of 'experimental:preprocessor'
cl : Command line warning D9002 : ignoring unknown option '-fno-strict-aliasing'
cl : Command line warning D9002 : ignoring unknown option '-fexceptions'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\complex(354): error C2039: 'copysign': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\complex(354): error C3861: 'copysign': identifier not found
Target //tensorflow/tools/pip_package:build_pip_package failed to build

Having the same issue trying to build tensorflow from master on windows. The problem seems to be about  library, but I don't understand what's wrong. I have exactly the same error with the same version of MSVC.

The copysign issue is caused by MSVC. See #46902, https://www.gitmemory.com/issue/OpenImageIO/oiio/2799/752372181, https://github.com/python/cpython/pull/23326

@nfisdnf986,
This issue was addressed in this MSVC repo issue. Could you take a look at this issue and let us know if the issue still persists. Thank you!

authors: Termina1 abattery mihaimaruseac nfisdnf986 pourfard terryheo tilakrayal ymodak


text:
I tried filling in all of your "form" & you closed off the issue so, were going to do this EVERY DAY until you act like grown ups

Backend terminated or disconnected.Fatal Python error: Illegal instruction
Current thread 0x00007f0f5412a740 (most recent call first):
File "", line 219 in _call_with_frames_removed
File "", line 1101 in create_module
File "", line 556 in module_from_spec
File "", line 657 in _load_unlocked
File "", line 975 in _find_and_load_unlocked
File "", line 991 in _find_and_load
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 285 in _custom_import
File "/home/ian/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64 in
File "", line 219 in _call_with_frames_removed
File "", line 783 in exec_module
File "", line 671 in _load_unlocked
File "", line 975 in _find_and_load_unlocked
File "", line 991 in _find_and_load
File "", line 219 in _call_with_frames_removed
File "", line 1042 in _handle_fromlist
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 285 in _custom_import
File "/home/ian/.local/lib/python3.8/site-packages/tensorflow/python/init.py", line 39 in
File "", line 219 in _call_with_frames_removed
File "", line 783 in exec_module
File "", line 671 in _load_unlocked
File "", line 975 in _find_and_load_unlocked
File "", line 991 in _find_and_load
File "", line 219 in _call_with_frames_removed
File "", line 961 in _find_and_load_unlocked
File "", line 991 in _find_and_load
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 285 in _custom_import
File "/home/ian/.local/lib/python3.8/site-packages/tensorflow/init.py", line 41 in
File "", line 219 in _call_with_frames_removed
File "", line 783 in exec_module
File "", line 671 in _load_unlocked
File "", line 975 in _find_and_load_unlocked
File "", line 991 in _find_and_load
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 285 in _custom_import
File "", line 1 in
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1272 in _execute_prepared_user_code
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1200 in wrapper
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1213 in wrapper
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1259 in execute_source
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 814 in _execute_source
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 444 in _cmd_execute_source
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 204 in handle_command
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 146 in mainloop
File "/usr/lib/python3/dist-packages/thonny/backend_launcher.py", line 87 in  Use 'Stop/Restart' to restart.

@IanSMoyes,
In order to expedite the trouble-shooting process, could you please provide the following details

OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
TensorFlow installed from (source or binary):
TensorFlow version:
Python version:
Installed using virtualenv? pip? conda?:
Bazel version (if compiling from source):
GCC/Compiler version (if compiling from source):
CUDA/cuDNN version:
GPU model and memory:

and the exact sequence of commands / steps that you executed before running into the error.
Thanks!

Please don't spam. Please follow the rules listed in the code of conduct

authors: IanSMoyes amahendrakar mihaimaruseac


text:
Tensorflow failed to build due to error C2039 C3861 on windows with MSVC

Hi All,
Tensorflow failed to build due to error C2039 C3861 on windows with MSVC. It can be reproduced on latest master branch commit. Could you please help take a look at this issue? Thanks in advance!
Environment
Tensorflow(latest master branch revision from github) + VS 2019 + Windows Server 2016
Note:
build.log in build.zip attachment.
build.zip
tensorflow_set_bazel_version.patch in tensorflow_set_bazel_version.zip
tensorflow_set_bazel_version.zip
Repro steps:

Open x64 native tools command prompt for VS2019
git clone https://github.com/tensorflow/tensorflow F:\gitP\tensorflow\tensorflow
git submodule init
git submodule update --recursive
Apply tensorflow_set_bazel_version.patch in attachment tensorflow_set_bazel_version.zip
cd F:\gitP\tensorflow\tensorflow
pip3 install six numpy wheel
pip3 install keras_applications==1.0.6 --no-deps
pip3 install keras_preprocessing==1.0.5 --no-deps
set PATH=F:\gitP\tensorflow\tensorflow..\tools;%path%
set PATH=F:\gitP\tensorflow\tensorflow..\tools\msys64\usr\bin;%path%
yes "" 2>nul | python ./configure.py
set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC
set BAZEL_VC_FULL_VERSION=14.28.29333
bazel --output_user_root F:\bazelTemp build --config=opt --subcommands //tensorflow/tools/pip_package:build_pip_package

Actual result:
SUBCOMMAND: # //tensorflow/core/platform:error [action 'Compiling tensorflow/core/platform/error.cc', configuration: b0b8ead46223da3f6648bba4bb6404871eb4a1826bc4e150e3d35eeda28b2f74]
SUBCOMMAND: # //tensorflow/core/platform:error [action 'Linking tensorflow/core/platform/error.lib', configuration: b0b8ead46223da3f6648bba4bb6404871eb4a1826bc4e150e3d35eeda28b2f74]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\complex(674): error C2039: 'copysign': is not a member of '`global namespace''
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\complex(674): error C3861: 'copysign': identifier not found
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 9803.671s, Critical Path: 681.63s
INFO: 9288 processes: 9288 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
##[debug] Command #6 exited with code [1].
##[error] Detected error code [1].

@spacelg,
Looks like this is a duplicate of issue #46902, which has already been addressed by a member of the TensorFlow team.
Please take a look at this comment for more information. Thanks!

authors: amahendrakar spacelg


text:
Multiple retracing when shapes changes

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: na
TensorFlow installed from (source or binary): binay pypy
TensorFlow version (use command below): 2.4.1
Python version: 3.7
Bazel version (if compiling from source):
GCC/Compiler version (if compiling from source):
CUDA/cuDNN version:
GPU model and memory:

Describe the current behavior
import tensorflow as tf
@tf.function()  # Setting experimental relax shapes does not change the result
def unique_numpy(arr):
    unique_val, unique_inverse = tf.unique(arr)
    return unique_val
# We trace two functions.
unique_numpy.get_concrete_function(tf.TensorSpec(shape=(None,), dtype=tf.int32))
unique_numpy.get_concrete_function(tf.TensorSpec(shape=(None,), dtype=tf.int64))
print(unique_numpy.pretty_printed_concrete_signatures()) # 2 signatures available
unique_numpy(tf.constant([0, 2], dtype=tf.int32))
print(' New')
print(unique_numpy.pretty_printed_concrete_signatures()) # 3 signatures while it should have re used the tf.TensorSpec(shape=(None,), dtype=tf.int32) trace

Describe the expected behavior
Since tf.constant([0, 2], dtype=tf.int32)respects the signature tf.TensorSpec(shape=(None,), dtype=tf.int32)I would have thought that TF would reuse that trace and not trace again the function.
I would like to do that to create a function with the same name that could support the same shape but multiple dtypes.
Standalone code to reproduce the issue
Done above
Other info / logs Include any logs or source code that would be helpful to

I am able to replicate the issue reported, please find the gist here

This is a bug, indeed. Here's a temporary workaround in case you're blocked by it:
cf = unique_numpy.get_concrete_function(tf.TensorSpec(shape=(None,), dtype=tf.int64))
cf(tf.constant([0, 2], dtype=tf.int32))  # guaranteed not to retrace

This should now be fixed at head, and should land in the next version.

authors: Saduf2019 mdanatg tanguycdls


text:
Support Workload Identity Federation authentication in GFile

Click to expand!
Issue Type
Feature Request
Source
binary
Tensorflow Version
2.9.0
Custom Code
No
OS Platform and Distribution
Ubuntu 20:04
Mobile device
No response
Python version
3.9
Bazel version
No response
GCC/Compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current Behaviour?
Workload Identity Federation is the new and preferred authentication mechanism to GCS on CI systems where long lived service account keys can pose a security risk according to https://github.com/google-github-actions/auth.

It would be great if TensorFlow gfile would be able to utilise this authentication mechanism as well.

Standalone code to reproduce the issue
A full reproduction can be found at https://github.com/google-github-actions/auth/issues/210

Relevant log output
No response

Any update on this from Googlers? This is a pretty tricky annoyance in our CI/CD workflows on GitHub Actions to Vertex and Dataflow, since gcloud just works while TensorFlow Datasets (tfds CLI and tfds.load) does not without jumping through hurdles.

Hi,
If this is issue is related to any security vulnerability of Tensorflow, could you please report it in the proper channel so that this will be taken on priority.
For more details on how to report these, please refer https://github.com/tensorflow/tensorflow/security/policy#vulnerabilities-in-tensorflow

cc @sachinprasadhs
Is there any update here either from Google or acceptable workaround found by the community? Workload Identity Federation has been in GA for 4+ years and is GCP's recommended pattern for impersonating service accounts vs. using service account keys. Pulling from GCP's own documentation for "Best practices for managing service account keys":

Service account keys can become a security risk if not managed carefully. You should choose a more secure alternative for authentication whenever possible. The main threats are related to service account keys are:

Credential leakage: Service account keys might inadvertently end up in places where they are not supposed to be stored. A bad actor can use a leaked service account key to authenticate and gain a foothold in your environment.
Privilege escalation: If a bad actor gets access to a poorly secured service account key, they might be able to use the key to escalate their privileges.
Information disclosure: Service account keys might inadvertently disclose confidential metadata.
Non-repudiation: By authenticating using a service account key and letting the service account carry out operations on their behalf, a bad actor might conceal their identity and actions.

cc @sachinprasadhs Is there any update here either from Google or acceptable workaround found by the community? Workload Identity Federation has been in GA for 4+ years and is GCP's recommended pattern for impersonating service accounts vs. using service account keys. Pulling from GCP's own documentation for "Best practices for managing service account keys":

Even better Google has now gone even farther introducing direct auth, allowing you to fully bring your own identity to authenticate directly with GCP APIs instead of using an impersonated service account at all. That's certainly not supported here either.

authors: carlthome derekheld fathom-nathan lgeiger sachinprasadhs


text:
Can I Pay My Apple Card Bill by Phone?

How can I recover my Apple Card +1(707)-767-1266 account? If you need to recover your Apple Card  account, you can contact their customer service hotline at +1(707)-767-1266 or +1(707)-767-1266 USA for assistance in the recovery process.
How to contact Apple Card  Manager? You can access live chat by clicking the "Contact Us" ☎+1(707)-767-1266 button in the help center and then selecting "Chat." Phone: Apple Card  also offers phone support for urgent issues. You can call Apple Card  at ☎+1(707)-767-1266 for Quick response & Support. There are in brief ways to talk to someone on Apple Card .
Does Apple Card  have a live chat? Yes, Apple Card  does offer a live chat option for customer support. To access the live chat feature:
Go to Apple Card 's Help Center on the platform.
Look for the "Contact Us" ☎+1(707)-767-1266 option.If you are trying to reach Apple Card  Support +1(707)-767-1266 (24/7), the only Apple Card  phone number is ☎+1-1(707)-767-1266 (24/7) or +1(707)-767-1266 USA for Quick response & Support. You can also access live chat by clicking the "Contact Us" button in the help center and then selecting "Chat."
Choose the chat option to speak with a live person.
You can also contact Apple Card  support at ☎+1(707)-767-1266 (Talk with Human) & (☎+1(707)-767-1266 (Contact-USA)).
Follow the prompts to describe your issue and get assistance.

Closing this issue as spam