How to include python files in tensorflow package build?

Question:
I want to use the following file :
from tensorflow.python.grappler import model_analyzer

But tensorflow by default does not have the model_analyzer.py in pip packages. I can’t find the file under .../envs/tfenv/lib/python3.8/site-packages/tensorflow/python/grappler/.
However, the model_analyzer.py is indeed under the tensorflow’s source directory at /tensorflow/tensorflow/blob/master/tensorflow/python/grappler/model_analyzer.py
Why tensorflow ignores these files under grappler directory? How should I build tensorflow for using these files?

Context:
Stonepia:

model_analyzer

I’m assuming that you need to analyze the model, as seen on file name.
I don’t know is it just the same things as TFMA but since the beginning I’ve been using TFMA for model analyzer. If you want to give it a try, you can install it with;
pip install tensorflow-model-analysis
Hope it helps.


Is Grappler’s autoparallel optimizer un maintained?

Question:
Is this optimizer currently unmaintained?
There is little docs about this. Also, it only applies to a few gradient ops from the code in tensorflow/core/grappler/optimizers.  The autoparallel pass is quite straightforward and could only apply to few scenario,  I think?
Could someone offer a little more information about this optimizer?

Context:
I think that the developmemt of these optimizations is going to migrate over MLiR

      TensorFlow

tf.config.experimental.enable_mlir_graph_optimization 8

  Enables experimental MLIR-Based TensorFlow Compiler Optimizations.


Question: What’s the meaning of loss & acc ? I mean they are loss and accuracy of training data but why the sum is not equal to 1?

Context:
Accuracy is a method for measuring performance based on the actual value and the predicted value.
Loss is a performance measure that is based on how much the predicted value varies from the actual value.
As they are different performance measures, their sum is not 1 (in most cases).


Converting categorical datasets into continuous?

Question:
Hi.  I’ve been working on my first TF project for a few weeks now in my spare time.  I’ve learned a ton but I’m still running into a few gaps in my understanding before I think I can get everything working.
I’m trying to use a CNN to predict a continuous value using images as input.  I’m using the functions from keras.preprocessing.image to load the datasets but they expect the labels to be categorical.  Is it possible to transform the labels into continuous values before training?
Like if I have categories [“1”, “2”, “3”] can I transform those labels to values [0.0, 0.333, 1.0] and run some kind of regression?
I’m having trouble finding resources for something like this so any help is super appreciated!

Context:
For further clarification, if it’s helpful.
My goal is to build a CNN-regression model.  I’d like to predict a continuous value with an image as input.  I’m not clear, reading the documentation, how to use the image-dataset functions provided in kera.preprocessing.image to load a dataset of images with numeric, continuous labeling.
Thanks!


Autograd fails for reduce_sum on ragged tensor

Question:
While using tf.reduce_sum with ragged tensors, I stumbled upon an issue where autograd produces an exception in graph mode. The following code fails:
@tf.function()
def f(x):
    return tf.reduce_sum(x, axis=-1)

def test_autograd():
    values = tf.random.uniform((8,), seed=213)
    sizes = tf.constant([4, 2, 2])
    x = tf.RaggedTensor.from_row_lengths(values, sizes)

    with tf.GradientTape() as tape:
        tape.watch(x.flat_values)
        y = f(x)

    grad = tape.gradient(y, x.flat_values)

If I run test_autograd, I get an error:
self = <tf.Operation 'RaggedReduceSum/UnsortedSegmentSum' type=UnsortedSegmentSum>
name = '_XlaCompile'

    def get_attr(self, name):
      """Returns the value of the attr of this op with the given `name`.

      Args:
        name: The name of the attr to fetch.

      Returns:
        The value of the attr, as a Python object.

      Raises:
        ValueError: If this op does not have an attr with the given `name`.
      """
      fields = ("s", "i", "f", "b", "type", "shape", "tensor", "func")
      try:
        with c_api_util.tf_buffer() as buf:
>         pywrap_tf_session.TF_OperationGetAttrValueProto(self._c_op, name, buf)
E         tensorflow.python.framework.errors_impl.InvalidArgumentError: Operation 'RaggedReduceSum/UnsortedSegmentSum' has no attr named '_XlaCompile'.

../../venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py:2328: InvalidArgumentError

During handling of the above exception, another exception occurred:

scope = 'gradients'
op = <tf.Operation 'RaggedReduceSum/UnsortedSegmentSum' type=UnsortedSegmentSum>
func = None
grad_fn = <function _GradientsHelper.<locals>.<lambda> at 0x7f206004f4d0>

    def _MaybeCompile(scope, op, func, grad_fn):
      """Compile the calculation in grad_fn if op was marked as compiled."""
      scope = scope.rstrip("/").replace("/", "_")
      if func is not None:
        xla_compile = func.definition.attr["_XlaCompile"].b
        xla_separate_compiled_gradients = func.definition.attr[
            "_XlaSeparateCompiledGradients"].b
        xla_scope = func.definition.attr["_XlaScope"].s.decode()
      else:
        try:
>         xla_compile = op.get_attr("_XlaCompile")

../../venv/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py:331:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tf.Operation 'RaggedReduceSum/UnsortedSegmentSum' type=UnsortedSegmentSum>
name = '_XlaCompile'

    def get_attr(self, name):
      """Returns the value of the attr of this op with the given `name`.

      Args:
        name: The name of the attr to fetch.

      Returns:
        The value of the attr, as a Python object.

      Raises:
        ValueError: If this op does not have an attr with the given `name`.
      """
      fields = ("s", "i", "f", "b", "type", "shape", "tensor", "func")
      try:
        with c_api_util.tf_buffer() as buf:
          pywrap_tf_session.TF_OperationGetAttrValueProto(self._c_op, name, buf)
          data = pywrap_tf_session.TF_GetBuffer(buf)
      except errors.InvalidArgumentError as e:
        # Convert to ValueError for backwards compatibility.
>       raise ValueError(str(e))
E       ValueError: Operation 'RaggedReduceSum/UnsortedSegmentSum' has no attr named '_XlaCompile'.

../../venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py:2332: ValueError

During handling of the above exception, another exception occurred:

    def test_autograd():
        values = tf.random.uniform((8,), seed=213)
        sizes = tf.constant([4, 2, 2])
        x = tf.RaggedTensor.from_row_lengths(values, sizes)

        with tf.GradientTape() as tape:
            tape.watch(x.flat_values)
>           y = f(x)

graphs/tf2_sandwich_model_test.py:170:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py:580: in __call__
    result = self._call(*args, **kwds)
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py:650: in _call
    return self._concrete_stateful_fn._filtered_call(canon_args, canon_kwds)  # pylint: disable=protected-access
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/function.py:1665: in _filtered_call
    self.captured_inputs)
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/function.py:1751: in _call_flat
    forward_function, args_with_tangents = forward_backward.forward()
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/function.py:1477: in forward
    self._inference_args, self._input_tangents)
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/function.py:1233: in forward
    self._forward_and_backward_functions(inference_args, input_tangents))
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/function.py:1385: in _forward_and_backward_functions
    outputs, inference_args, input_tangents)
../../venv/lib/python3.7/site-packages/tensorflow/python/eager/function.py:943: in _build_functions_for_outputs
    src_graph=self._func_graph)
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py:669: in _GradientsHelper
    lambda: grad_fn(op, *out_grads))
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py:336: in _MaybeCompile
    return grad_fn()  # Exit early
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py:669: in <lambda>
    lambda: grad_fn(op, *out_grads))
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/math_grad.py:470: in _UnsortedSegmentSumGrad
    return _GatherDropNegatives(grad, op.inputs[1])[0], None, None
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/math_grad.py:438: in _GatherDropNegatives
    dtype=is_positive_shape.dtype)],
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py:2967: in ones
    output = _constant_if_small(one, shape, dtype, name)
../../venv/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py:2662: in _constant_if_small
    if np.prod(shape) < 1000:
<__array_function__ internals>:6: in prod
    ???
../../venv/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3031: in prod
    keepdims=keepdims, initial=initial, where=where)
../../venv/lib/python3.7/site-packages/numpy/core/fromnumeric.py:87: in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tf.Tensor 'gradients/RaggedReduceSum/UnsortedSegmentSum_grad/sub:0' shape=() dtype=int32>

    def __array__(self):
      raise NotImplementedError("Cannot convert a symbolic Tensor ({}) to a numpy"
>                               " array.".format(self.name))
E     NotImplementedError: Cannot convert a symbolic Tensor (gradients/RaggedReduceSum/UnsortedSegmentSum_grad/sub:0) to a numpy array.

../../venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py:749: NotImplementedError

If I call tf.reduce_sum directly in the test (without going through f), it does work though. How can I avoid this problem?

Context: What is your TF version?


Introducing TensorFlow to high school students

Question:
Hi! Joined today during the TensorFlow Community Team meet.
I have found learning new things is easier when doing some lessons for a local high school I volunteer at.
I see the following resources and have also gone through the freecodecamp resource:

      TensorFlow

Machine learning education  |  TensorFlow 41

  Start your TensorFlow training by building a foundation in four learning areas: coding, math, ML theory, and how to build an ML project from start to finish.

Any tips or suggestions on your favorite intro course (accessible to learners, 14-18) would be much appreciated. Either from anyone who has undertaken this themselves or has some ideas on how they might do it.
Thanks, and excited to be here.

Context: If your students know and use Python, I created an “ML Foundations” course on YouTube. You can find it on the YT channel, and it might work well for them.


Looking for a mentor in ML and MLOps using TensorFlow

Question:
Hello All
I am looking for a mentor in my journey of becoming a machine learning engineer. I would like to contact GDEs for this. What is the best way to contact them ?
Thanks
Balu

Context:
Adding @Soonson_Kwon who might have a better insight on who to get in touch with from the GDE Program!
Also @Sayak_Paul fyi!


Keras TF2.0 SavedModel Input/Output Nodes

Question:
Hello!
I am trying to perform model conversions on a TensorFlow2.0 SavedModel and I need to know what the input nodes, input dimensions, and output nodes are. I am trying to use the ‘graph_transforms:summarize_graph’ tool but I keep getting the following error: Can’t parse saved_model.pb as binary proto (both text and binary parsing failed for file saved_model.pb)
I also tried to visualize the graph using Tensorboard, but it provides complicated graphs that are not so obvious.
Any recommendations?
Thanks,
Ahmad

Context:
Have you tried using GitHub - lutzroeder/netron: Visualizer for neural network, deep learning, and machine learning models 16 to visualize your model.
You may try using browser version that allows you to quickly upload your model and it displays op level graph.


Question: Hello, TensorFlow is, it seems to me under MIT license, I saw that there was tensorFlow JS, like a lot of people I have an allergy to JavaScript, is there an official PHP version planned, there is many forks, but hey … and I prefer to limit, as much as possible JSON

Context:
Not as a wrapper.
Instead if you need to consume model inference with PHP you could use the serving REST API

      TensorFlow

RESTful API  |  TFX  |  TensorFlow 10


Question: Excuse me does anybody know how to transfer learning a Faster RCNN to my own dataset? Or is there any reference for that? because I still don’t understand is it included as my base network in my model or what. Thank you very much

Context:
How about the following, though I’ve not tested this yet:

In TensorFlow Hub (a repository of pre-trained TensorFlow models), click on/search for “object detection” models: (link to Image Object Detection results: TensorFlow Hub 25)

In the results, there is faster_rcnn/openimages_v4/inception_resnet_v2  (link: TensorFlow Hub 17)

Object detection model trained on Open Images V4 with ImageNet pre-trained Inception Resnet V2 as image feature extractor.

FasterRCNN+InceptionResNetV2 network trained on Open Images V4.

Then, check out the Transfer learning with TensorFlow Hub  |  TensorFlow Core 28 tutorial.

Looping in @lgusm (DevRel) and the docs team - notebook co-authors @billy @markdaoust


Some impressive tutorial to learning TFX

Question:
in this topic, you will find some impressive tutorial that will help you to learn TFX

1200×675 31.3 KB

Resources

TensorFlow Page  10
TensorFlow Extended (TFX) 8
ML Pipelines on Google Cloud 10
Manage a production ML pipeline with TFX 15
How to build an ML pipeline with TFX 9
 MLOps Specialization  5

I hope it will help you and feel free to add more tutorial

Context:
The MLOps Specialization on Coursera is also great:

      Coursera

Machine Learning Engineering for Production (MLOps) 9

  Offered by DeepLearning.AI. Become a Machine Learning expert. Productionize your machine learning knowledge and expand your production ... Enroll for free.


TensorFlow Lite for Microcontrollers with Arduino uno

Question:
Hi there
I plan to build   a machine learning project with Tesnsorflow lite and Arduino for The TensorFlow Microcontroller Challenge 25
and I have a question, it is possible to implement a tflite model on Arduino UNO or not?
and if you give me an example I will be thankful

Context:
Hey Kareem!
Check this session during #GoogleIO .
Building with TensorFlow Lite for microcontrollers 43
This may help you.
Thanks.


F.interpolation alternative in tensorflow

Question:
Hi,
What is the alternative op of PyTorch F.interpolation in TensorFlow
Thanks

Context:
You could use tf.image.resize:

      TensorFlow

tf.image.resize  |  TensorFlow Core v2.5.0 3

  Resize images to size using the specified method.


Question:
I was looking for a model to process French sentences, but I can’t find any for TF.js. So, using tensorflowjs_converter, I tried to convert the universal-sentence-encoder-multilingual model (TensorFlow Hub 2), but it’s not working.
I get an error “Op type not registered ‘SentencepieceOp’ in binary running”
Is there an existing multilingual model available for TF.js or a way to make it work?
Thanks!

Context: Have you checked TF2.0 hub Universal Sentence Encoder Multilingual Sentenepieceop not registered problem · Issue #463 · tensorflow/hub · GitHub 7?


Export Control Classification Number (ECCN) of TensorFlow

Question: Can someone please if TF has an ECCN, and if yes, what it is?

Context:
I don’t think we have specific info. See

      github.com/tensorflow/tensorflow

      Export Control Classification Number (ECCN) for Tensorflow 11

        opened

        Jan 22, 2019

          closed

        Jan 23, 2019

          zygfrydw

    **System information**
- TensorFlow version: 1.8.0
- Doc Link:

I would like… to use Tensorflow in commercial software which will be sold in the U.S. For this reason, the legal department asks me about Export Control Classification Number (ECCN) for Tensorflow library. From my understanding, the open sources software is not subject to [Encryption and Export Administration Regulations (EAR)](https://www.bis.doc.gov/index.php/policy-guidance/encryption/1-encryption-items-not-subject-to-the-ear).
Can anyone confirm that Tensorflow is not a subject to EAR or point a ECCN class for Tensorflow?

Does Tensorflow use any encryption functionality, which should be mention when applying for ECCN for software which uses Tensorflow?


Question:
Grappler offers an autoparallel optimizer as stated in (TensorFlow graph optimization with Grappler  |  TensorFlow Core 6).
But there is no explicit tools for setting the flag, the tf.config.optimizer.set_experimental_options() does not offer this option (auto_parallel) either.
How could I enable this? Thanks in advance

Context:
It is available but not documented. I think you could  open a Docoumentation type issue on Github 1

      github.com

    tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/rewriter_config.proto#L14-L17 3

          message AutoParallelOptions {
            bool enable = 1;
            int32 num_replicas = 2;
          }

      github.com

    tensorflow/tensorflow/blob/master/tensorflow/core/protobuf/rewriter_config.proto#L177-L179 3

          // Configures AutoParallel optimization passes either through the
          // meta-optimizer or when manually specified through the optimizers field.
          AutoParallelOptions auto_parallel = 5;


Question:
Hi guys,   could you please shed light on the following?
Requirement:

Create a sequence predictor based on geometric shapes
Shapes can be circles, rectangles and triangles
Such  shapes can vary in size and angles if they have
The sequencer should try to predict the most likely next shape and its size.

What has been tried:
Basics:

The data has been normalized
Training data,  validation data and test data are separate and different sets

Implementation:

Passed the shape’s numeric data as part of the sequence e.g. the points that represent the triangle,  it seems the LSTM is trying to do some math with it and it never picks a pattern, I guess, given the different shapes
Make the shape’s point strings and use a categorical LSTM:  the strings are so varied that no pattern is picked
Round the numbers of the dimensions and make them string: too much precision gets lost and  I get a crazy big dictionary , no pattern is picked

In all cases the Test data evaluation is no more than 40% accurate
Any ideas to tackle this type of requirement?
Thanks!

Context:
Hello George,
I’m not sure how much this will help, but here are a few things I might think about too. And these might be things you’re already thinking about too!
First is to be careful with how the data is normalized, think about the domain and range of your inputs and outputs. If all of your circles have a max radius of 10, it might be hard for your model to predict a number larger than that.
Second is maybe you can describe the shapes differently than points. I’m not sure exactly what your data looks like, but coordinates I think might not be important. Without putting the shapes on a coordinate system, you could define any rectangle for example with just a height and width, any circle could be defined with just a radius, and I think a triangle could be defined with two side lengths and the angle between them. You could use these simpler representations as inputs and outputs, and maybe they would be easier for the model to pick up.
Third is maybe try breaking up the problem a bit, like first predicting what type of shape comes next, then predicting the dimensions and size of that shape.
I hope this helps a bit!


“To discuss” Do you think TFX is enough to complete a full MLops project?

Question:
Hi, I am very interested in the TFX project and started learning and contributing to it on GitHub
And I hope one day I will become a member of TFX Team
In this topic, I want to discuss the readiness of TFX to complete the MLops pipeline
Does just learning TFX get you ready to complete projects or will you need more tools to complete your project?
Excited to hear from the TensorFlow team’ answers

Context:
In my opinion, tfx provides enough features to complete mlops project but you will need additional engineering to do it.
tfx helps a large part of mlops.


Question:
I’m interested in learning tensor flow. I have a real world problem where I have two tables of data, the data is made up of columns of types strings, numbers and dates.
Each row in table 1 has an equivalent entry in table 2. The data in table 2 will be similar but not exactly equal to it’s equivalent in table 1. Is it possible to use tensor flow to identify which records are related to each other?

Context:
That’s a great question!
I think it depends how you define that “relation”. You may be familiar with some of these methods, but please check them out if you’re not! You could do something like an encoder decoder network, and then compare the encodings with a distance similarity (like cosine distance). But you could also try that with a method like PCA.
Encoding and PCA, in a simplified sense, take your records and convert them to a few numbers, so you can then just compare the numbers with some distance formula. There are some great tutorials on using Keras for encoders, so please check them out!
Scikit-learn has some good documentation on PCA (principal component analysis), and the tensorflow and keras site have some good code examples, including some on encoders (usually with images, but it’s the same concept).
I hope this helps!


Any suggestions to start with TensorFlow?

Question: I am a high school student and ML is very fascinating to me. That’s why I spent most of my last year studying ML and deep learning algorithms (using python). A few months ago, I came to know about TensorFlow so I tried its keras.layers to make some custom models. It’s a great tool but it’s like a sea of features which makes it very complicated too (at least for me). So I am looking for some suggestion about where can I start learning it or some learning path or some guide. ThankYou.

Context:
Hello! Check out these posts in a related thread:

    Introducing TensorFlow to high school students General Discussion

    If your students know and use Python, I created an “ML Foundations” course on YouTube. You can find it on the YT channel, and it might work well for them.

    Introducing TensorFlow to high school students General Discussion

    Hi @dan  To add to what @Laurence_Moroney said, you can also check out the MOOCs mentioned on this page: Basics of machine learning  |  TensorFlow featuring @Laurence_Moroney and @Magnus
Also, if you haven’t already, check out the notebooks you can run in Colab: Machine Learning Basics with Keras (under TensorFlow.org Tutorials: Basic classification: Classify images of clothing  |  TensorFlow Core) and TensorFlow Basics (under TensorFlow.org Guides: Eager execution  |  TensorFlow Cor…

    Introducing TensorFlow to high school students General Discussion

    Hi @dan, here are two book recommendations you can use to learn more (both are excellent).

Manning | Deep Learning with Python, Second Edition
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition [Book]

    Introducing TensorFlow to high school students General Discussion

    Hi @dan ,
I am also a high school student working with TensorFlow. I personally started off learning Machine Learning from Andrew Ng’s courses and strongly think they could build the basics for students. To learn specifically about TensorFlow I used and would recommend:

TF in Practice (now called TensorFlow Developer)
TF: Data and Deployment

by @Laurence_Moroney . Apart from this, I think the official TensorFlow Guide is a quite systematic approach to learn. Being in High school myself, anot…


Question:
First, thanks for the forum. It was much needed
Second, there could be another tag on TFLite.
Third, we have a TFLite working group that consists of ML GDEs, Googlers like Khanh and Hoi, and other community contributors that are passionate about the TinyML revolution. The working group has emerged to be one of the most active ones and together we have been able to:

Develop mobile applications that demonstrate best and advanced practices of TFLite.
Publish state-of-the-art TFLite models (from different data modalities) on TensorFlow Hub.
Write in-depth technical tutorials.

To better recognize these efforts, I think it might be a great option to also host something similar to what Jason does with TFJs ShowAndTell. Looking forward to hearing what others have to say.

Context: Not able to include links in my post. But in case if someone is interested to see where we track all of the aforementioned efforts, go over to ml-gde/e2e-tflite-tutorials 11 on GitHub.


Question: how to create a dataset sampling patches from WSI randomly.

Context: Do you have already tested GitHub - SarderLab/tf-WSI-dataset-utils: An optimized pipeline for working with Whole Slide Image (WSI) data in Tensorflow 18 ?


Question: Hey, Guys I want to build a recommendation system using TF or TF.js for my web application ,Can I get suggestions on blogs or videos I could refer.

Context:
Have you already explored TensorFlow Recommenders (TFRS)?

      blog.tensorflow.org

Introducing TensorFlow Recommenders 15

  Introducing TensorFlow Recommenders, a library for building flexible and powerful recommender models.


Question:
I have a TF 1.14 model which uses “tf.contrib.rnn.LSTMBlockFusedCell”, which I am trying to replicate in TF2.4.  It is a variant of “DeepSpeech, v. 0.5.1”.
Both models have one LSTM and five Dense layers.
The layer weights are loaded from a DeepSpeech v. 0.5.1 Checkpoint into the TF2.4 model,
taking care to split kernel from recurrent_kernel, and re-ordering the blocks
(i,c,f,o) → (i,f,c,o) as suggested by a kind person here.
The models take same input, all other layers (the five Dense layers) have same inputs and outputs, only the LSTM layers have different outputs in teh two models.
The final outputs are in the same order of magnitude, but the TF2.4 result is not close to correct, that is: does not translate audio to text, which the TF1.14 model does almost satisfactorily.
Does anyone here know whether Tensorflow.keras.LSTM and  tf.contrib.rnn.LSTMBlockFusedCell are in fact designed to work identically?  Am I wasting my time trying to get the same results?

Context:
I don’t know if you could be interested to explore the upstream diff on how they are refactoring the model (to remove also the old contrib):

      github.com/mozilla/DeepSpeech

      Low touch upgrade to TensorFlow 2.3 15

      mozilla:master ← mozilla:low-touch-r2.3

        opened

        Jan 2, 2021

          reuben

          +476
          -1252

    Keeps changes to a minimum by leveraging the fact that under a `tfv1.Session` ob…ject, TensorFlow v1 style meta-graph construction works normally, including placeholders. This lets us keep changes to a minimum. The main change comes in the model definition code: the previous LSTMBlockCell/static_rnn/CudnnRNN parametrized RNN implementation gets replaced by `tf.keras.layers.LSTM` which is supposed to use the most appropriate implementation given the layer configuration and host machine setup. This is a graph breaking change and so GRAPH_VERSION is bumped.


Audio classification: Getting train_function error when trying to fit model

Question:
The title describes the gist of the issue, details and code are here: python - Getting "Function call stack: train_function -> train_function" error when training tensorflow2 LSTM RNN - Stack Overflow 14
Does anyone know why this error is happening? I cannot for the life of me figure it out.

Context:
Guy_Berreby:

python - Getting “Function call stack: train_function → train_function” error when training tensorflow2 LSTM RNN - Stack Overflow

Hi @Guy_Berreby, what type of music data are you working on? For instance, if it’s in a MIDI format, then I can see why you’re using the LSTM architecture. I also noticed you’re using tfio.audio.AudioIOTensor ( tfio.audio.AudioIOTensor  |  TensorFlow I/O 2) - maybe your two datasets are waveform-based. Can you please share some info and how you’re loading the data (code)?
I’ve summarized your code and the task below with some formatting, based on the information in the StackOverflow post you shared. @Guy_Berreby do let me know if the spaces and other info are correct, I had to make some minor adjustments:

Your ML task

Music genre classification, two different genres - bm and dm

Code

RNN (LSTM) model:

model = keras.Sequential()
# Add an Embedding layer expecting input vocab of size 1000, and
# output embedding dimension of size 64.
model.add(layers.Embedding(input_dim=maxLen, output_dim=2,mask_zero=True))
#model.add(layers.Masking())
# Add an LSTM layer with 128 internal units.
# model.add(layers.Input(shape=[1,None]) )
model.add(layers.LSTM(8,return_sequences=True))
model.add(layers.Dropout(0.2) )

model.add(layers.LSTM(8))
model.add(layers.Dropout(0.2) )

# Add a Dense layer with 10 units.
model.add(layers.Dense(16,activation="relu"))
model.add(layers.Dropout(0.2))

model.add(layers.Dense(2,activation="softmax"))
model.compile(loss='categorical_crossentropy', optimizer='adam')

Generator:

def modelTrainGen(maxLen):
  # One type of music - training set
  bmTrainDirectory = '/content/drive/.../...train/'
  # Another type of music - training set
  dmTrainDirectory = '/content/drive/.../...train/'

  dmTrainFileNames = os.listdir(dmTrainDirectory)
  bmTrainFileNames = os.listdir(bmTrainDirectory)
  maxAudioLen = maxLen
  bmTensor = tf.convert_to_tensor([[1],[0]])
  dmTensor = tf.convert_to_tensor([[0],[1]])
  allFileNames = []

  for fileName in zip(bmTrainFileNames,dmTrainFileNames):
    bmFileName = fileName[0]
    dmFileName = fileName[1]
    allFileNames.append((bmFileName,1))
    allFileNames.append((dmFileName,0))

    random.shuffle(allFileNames)
    for fileNameVal in allFileNames:

    fileName = fileNameVal[0]
    val = fileNameVal[1]

    if val == 1:
      bmFileName = fileName
      audio = tfio.audio.AudioIOTensor(bmTrainDirectory + bmFileName)
      audio_slice = tf.reduce_max(tf.transpose(audio[0:]),0)
      del audio
      print(audio_slice.shape)
      padded_x = tf.keras.preprocessing.sequence.pad_sequences( [audio_slice], padding="post",
      dtype=float,maxlen=maxAudioLen )
      del audio_slice
      converted = tf.convert_to_tensor(padded_x[0])
      del padded_x
      print("A")
      print(converted.shape)
      yield ( converted,bmTensor)
      print("B")
      del converted

    else:
      dmFileName = fileName
      audio = tfio.audio.AudioIOTensor(dmTrainDirectory + dmFileName)
      audio_slice = tf.reduce_max(tf.transpose(audio[0:]),0)
      del audio
      print(audio_slice.shape)
      padded_x = tf.keras.preprocessing.sequence.pad_sequences( [audio_slice], padding="post", dtype=float,maxlen=maxAudioLen)
      del audio_slice
      converted = tf.convert_to_tensor(padded_x[0])
      del padded_x
      print("C")
      print(converted.shape)
      yield ( converted,dmTensor)
      print("D")
      del converted

(The following TensorFlow docs are for waveform-based data - could be useful in future:

Audio Data Preparation and Augmentation  |  TensorFlow I/O 2
Simple audio recognition: Recognizing keywords  |  TensorFlow Core 2

Transfer Learning with YAMNet for environmental sound classification 2 )


Question:
We’ve done 12 courses on TensorFlow at Coursera for TensorFlow:In Practice; TensorFlow: Data and Deployment; and TensorFlow: Advanced Techniques.
We have an upcoming specialization on MLE covering TFX etc
We also influenced their NLP and Medical AI specializations.
What would you want to see next?

Context: Reponsible AI Practices with TensorFlow.


TypeError: dataset length is unknown tensorflow

Question:
I was playing with this function from tf.data called tf.data.Dataset.from_generator() where it takes a ImageDataGenerator object and turns it into a Dataset Object. Everything was fine but when I fit my model I can’t use steps_per_epoch and validation_steps including them throws an error,

Screenshot 2021-05-20 at 3.39.15 AM1153×541 68.5 KB

TypeError: dataset length is unknown.
Then I commented them out and continued to fit the model but its training for infinitely seems there is no stopping. I have attached my images. (edited)

Screenshot 2021-05-20 at 3.15.58 AM709×637 42.8 KB

When I use .from_generator it automatically converts from ImageDatagenerator to a Dataset object but not sure why it’s still considering it as a generator and throwing error.
Any help on this?

Context:
ashikshafi0:

tf.data.Dataset.from_generator()

Looping in @Andrew_Audibert
I also checked for similar Issues here (keyword: tf.data.Dataset.from_generator -  Issues · tensorflow/tensorflow · GitHub 13) - in case someone has encountered a similar issue.


Is Tensorflow Swift not proceeding anymore?

Question:
I can not find tf swift here and github.
Is it archived??

Context: Are you looking for this one? GitHub - tensorflow/swift: Swift for TensorFlow 4


Greets for Newbies | Asking Suggestion to Kickstart

Question:
How you guys, going to greet for tensorflow newbie’s like me.
PS:- This post is open to share suggestion to help learn tensorflow learn efficiently with experienced professional.

Context:
Check out this thread which covers a lot of material for new TensorFlow users:

    Introducing TensorFlow to high school students General Discussion

    If your students know and use Python, I created an “ML Foundations” course on YouTube. You can find it on the YT channel, and it might work well for them.

Hope this helps! cc @Laurence_Moroney @jbgordon @lgusm @Jason


Question:
I would like to get some help to make tf.js run in this environment/setup:

GraalVM: https://www.graalvm.org/ 4

TypeScript: https://www.typescriptlang.org/ 2

Do you think it is possible? I’m still pretty new to TypeScript so a sample code/project would be very helpful. Here’s my current tsconfig if it helps:

{
“compilerOptions”: {
“module”: “amd”,
“target”: “es5”,
“moduleResolution”: “node”,
“allowJs”: true,
“sourceMap”: false,
“newLine”: “LF”,
“esModuleInterop”: true,
“baseUrl”: “.”,
“rootDir”: “./src/TypeScript/”,
“outDir”: “./src/FileCabinet/SuiteApps/com.netsuite.unittestreference/src”,
“lib”: [“es2015”, “dom”],
“skipLibCheck”: true,
“paths”: {
“N”: [“node_modules/@hitc/netsuite-types/N”],
“N/": ["node_modules/@hitc/netsuite-types/N/”],
“n”: ["./src/TypeScript/types/n"],
“n/": ["./src/TypeScript/types/n/”]
}
},
“exclude”: ["./test//", "./src/TypeScript/types/"],
“include”: ["./src/TypeScript//*"]
}

I tried using the CDN version and I got this error:
Error: Could not find a global object [at Rg (/SuiteApps/com.netsuite.unittestreference/src/app/HelloTypeScriptPage/main/tf.min.js:17:125032)]
I also tried the npm version, the tf.js doesn’t seem to be automatically built by TypeScript. I have some experience on webpack. Should I use a bundler?

Context: Looping in @Jason


Question:
This is primarily for the folks working in TensorFlow Lite and on-device ML.
Today, I gave a short talk at this meetup:

      gdg.community.dev

Machine Learning developers Meetup [EMEA/APAC] | Google Developer Groups 6

  I’m attending the I/O Community Lounge Meetups meetup on May 20, 2021! Learn more and join me: https://gdg.community.dev/e/mnrmef/ @GDG

I talked about the collaborative efforts TensorFlow Lite community has been making from the last year:

      docs.google.com

Community Ecosystem of TFLite 9

Community Ecosystem of TensorFlow Lite Sayak Paul PyImageSearch @RisingSayak

image1312×724 30.3 KB

image1264×687 114 KB

image1219×661 95.2 KB

@lgusm @Laurence_Moroney

Context: I really loved the talk and it was pretty great seeing so much awesome work by the TFLite Community. Thanks for sharing the slides!


Equivalent of “torch.cuda.LongTensor” in tensorflow

Question:
Hello,
I try to convert an existing code in pytorch to tensorflow. In the original code, they use “dtype=torch.cuda.LongTensor” to specify using GPU. Is there any alternative in tensorflow ? I have tried to use classical types of tensorflow such as “dtype =tf.dtypes.int64” but the code is very slow.
Thank you for your help.

Context:
Hello,
the device placement can be specified using tf.device in this way:
with tf.device("/gpu:0"):
    x = tf.Variable(shape, dtpe=tf.int64) # shape is a variable defined somewhere, with the shape

In this case the x variable is placed in the first GPU, and the type is 64 bit integer


RandAugment for Image Classification for Improved Robustness

Question:
Hi folks,
I always wanted to use RandAugment to improve the robustness of my vision models. But never found a straightforward example that showed how to use it in the context of TensorFlow and Keras.
Now, together with the community, we have one such example showing a clear advantage of RandAugment for improving the robustness of vision models:

      keras.io

Keras documentation: RandAugment for Image Classification for Improved... 27

The example shows how to use the imgaug library together with tf.py_function inside tf.data pipelines. Of course, it has its own demerits. But hey, that’s life!

Context:
Nice but It could be useful to expose to the user what we have  at models/augment.py at master · tensorflow/models · GitHub 10
models/augment.py at master · tensorflow/models · GitHub 9
Probably TF ops could have a better performance then tf.py_function with imageaug.


Why there is no YOLO models at TensorFlow Hub or Model Garden

Question: I would like to retrain a YOLOv4 model, but I prefer a more mainstream environment than the Darknet. I looked at the catalog of models at TensorFlow Hub and Model Garden, but there is no YOLO models there. YOLO achieves the fastest frame rates for object detection in many benchmarks. What is the reason for a lack of official Google support? Is it just a sheer quantity of various models to support or superior models already available at TensorFlow Hub and Model Garden?

Context:
Hi Paul,
publishing models on TFHub or Model Garden depends on the model creator to decide to do so.
Researchers from Google published multiple Object Detection models 200 that can be fine tuned using Model Maker 76.
For Yolo specifically, I guess the problem is that the creator didn’t want to publish it on TFHub yet. Would be great if they did.


What is the best approach to debug in TensorFlow when working with the C++ code base?

Question: In the past, I’ve had issues debugging in TensorFlow where the problem was somewhere in the C++ code base and I was using gdb, these included debug builds being too large (using -O0) and running out of space, recompile time etc. Does anyone have recommendations to handle debugging in TensorFlow?

Context:
I think that some of these problems are well known. For a recent experience you can follow this:

      github.com/tensorflow/tensorflow

      cannot build TensorFLow with --config=dbg 26

        opened

        May 6, 2021

          bas-aarts

  when building opensource TensorFlow with
bazel build --config=dbg --config=cuda --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" //tensorflow/tools/pip_package:build_pip_package
(for SM 7.0 only)
The build dies at link time with:
ERROR: /home/baarts/tensorflow-GH/tensorflow/python/BUILD:3373:24: Linking...

    subtype: ubuntu/linux
    subtype:bazel
    type:build/install

In the end there is a draft proposal so If you have something technical to share about your experience please leave a comment in the ticket.


Docs contributions and support channels footer

Question:
What do you think about adding a Docs contributions and support links footer in every Docs webpage like in Github Docs 2

image1137×234 21 KB

Context: Interested to hear your thoughts @billy.


Randomly sampling equal points ensuring equal number per class

Question:
Hi folks.
Currently, I have a requirement for a batch of data that should have an equal number of samples from each of the given classes.
I am implementing it using the naive way for CIFAR10:
def support_sampler():
    idx_dict = dict()
    for class_id in np.arange(0, 10):
        subset_labels = sampled_labels[sampled_labels == class_id]
        random_sampled = np.random.choice(len(subset_labels), 16)
        idx_dict[class_id] = random_sampled
    return np.concatenate(list(idx_dict.values()))

def get_support_ds():
    random_balanced_idx = support_sampler()
    temp_train, temp_labels = sampled_train[random_balanced_idx],\
        sampled_labels[random_balanced_idx]
    support_ds = tf.data.Dataset.from_tensor_slices((temp_train, temp_labels))
    support_ds = (
        support_ds
        .shuffle(BATCH_SIZE * 1000)
        .map(agumentation, num_parallel_calls=AUTO)
        .batch(BATCH_SIZE)
    )
    return support_ds

Is there a better way? Particularly using pure TF ops with tf.data?

Context:
Here the approach I used was to make a dataset for each class, and then merge them.

      TensorFlow

Classification on imbalanced data  |  TensorFlow Core 13

I used sample_from_datasets so it’s approximately equal. But you could also zip the datasets then and .map a function to stack all the zipped tensors.


Question:
I currently have a virtual environment inside which I have installed all the packages that I want (tensorflow, … ) and I use it to work locally. I constantly update the packages to the latest releases however, I am usually stuck on python 3.6
Is it the best approach to work locally? Or are containers a better approach where I can easily update my packages including python’s version.
If so, is there any guideline on how to create my environment inside containers?
Thanks!
Fadi

Context: I found while containers have more of a learning curve they are much easier in the long run. TensorFlow even has containers with source so you can build TensorFlow versions you need without installing a bunch of tooling on your system. If you use a GPU Nvidia-docker is by far the easiest way to get up and running with TensorFlow on a GPU. Best of all you avoid the “it works on my machine” issues where you can ship your container to the cloud or provide them to other developers to pickup and join your project.


Question:
I’m currently working on a project where of course the question of neural networks comes up. We are working on a fairly simple regression problem that has some noise in the data. My current approach is testing a few different networks including Random Forest and XGBoost.
I did run some test with TensorFlow but I didn’t see much better results to justify the increased training time.
However I figured I should ask people a bit more seasoned than myself, why should I use TensorFlow for a simple regression algorithm on structured data?
Thanks!

Context: If the problem is the model itself have you tried to explore the model space with AutoKeras 8?


How do you prefer to learn how to code with TensorFlow?

Question:
Are you a book person? A give-me-a-sample-that-I-can-take-apart person? A video tutorial watcher? Someone who loves to parse deep into the technical docs? Or some combination of all of the above?
What has worked for you in learning TensorFlow, Machine Learning, or indeed anything?

Context:
For a scientific topic like Machine Learning (or any academic topic from fluid dynamics to literary linguistics), my approach is usually Full-length video courses + TextBooks.
For a practical platform like TensorFlow I tend to start (phase 1) with a couple (2-5) of video tutorials for a high level overview. I then move to (phase 2) written tutorials that show code samples and explain the code. The more samples and the smoother the progression from simple to more complex the better. After a couple (again 2-5) of tutorials I move to (phase 3) trying to implement a few things relying on documentation (official guide/API docs).
Books sometimes can be part of phase 2 as some books are basically written as very good tutorials (like these 3 here 2).


What contributor documentation improvements do you suggest?

Question:
The TensorFlow team is doing a pass on the contributor documentation we have on tensorflow/tensorflow 7, tensorflow/community 9, and the website 7.
Based on your experience in contributing to TensorFlow, are there any docs that could use improvements for a better experience? Are there any docs that are missing?
Looking forward to your suggestions!
cc @billy for visibility

Context: And also on tensorflow/docs 11


How important is a managed solution for production ML?

Question: How do you want to run your production ML infrastructure?  Do you prefer cloud or on-prem deployments? For cloud, do you prefer managed or self-managed?

Context:
This is a great question for a thorough discussion.
I usually prefer the cloud and decide whether or not to use a managed service based on several considerations. First, if the service is supposed to run infrequently at unpredicted times (usually at early stages of an application), I prefer managed services as they give me a predictable cost overview. It also helps me avoid issues caused by cold start in the serverless. I simply dockerize my services and docker-compose-up them with different .env files in dev and prod environments. This seems a bit like hacky but yields a great productivity at early stages.
As my application starts to get attension and have a more regular usage pattern, I start to migrate / upgrade Docker containers to managed services one by one. Finally, I try to implement MLOps best practices for CI/CD/CT.
This workflow helps me remain experimental, fast-prototyping and cost-effective at early stages and then become gradually more robust, tested, scalable and manageable.
I love to hear from others’ experiences in this.


A deck on the key trends in computer vision with deep learning

Question:
I wanted to share with you a sneak peek of a deck I have prepared for an upcoming talk. The deck tries to focus on five key trends in computer vision in 2021. Of course, it’s not an exhaustive summary and it largely relates to what I have been mostly working on these days.
Here’s where you can find the deck: https://bit.ly/trends-cv 13. Folks that are a part of the ML-GDE Group can directly comment on the deck.
Aappreciate any feedback.

Context:
Nice deck Sayak! Well Done!
I guess you can also add Efficientnet V2 2 to slide 9 later


Suggestions regarding loss scaling in a distributed training loop

Question:
Hi folks.
I am currently implementing a custom training loop by overriding the train_step() function. I am also not using the default compile() method. So, I believe loss scaling is to be implemented.
Here’s how the fundamental loop is implemented (that runs as expected on a single GPU):
 with tf.GradientTape() as tape:
    fake_colorized = self.gen_model(grayscale)
    fake_input = tf.concat([grayscale, fake_colorized], axis=-1)
    predictions = self.disc_model(fake_input)
    misleading_labels = tf.ones_like(predictions)
    g_loss = - self.loss_fn(misleading_labels, predictions)
    l1_loss = tf.keras.losses.mean_absolute_error(colorized, fake_colorized)
    final_g_loss = g_loss + self.reg_strength * l1_loss

self.loss_fn is binary cross-entropy.
Here’s how the distributed variant is implemented:
with tf.GradientTape() as tape:
    fake_colorized = self.gen_model(grayscale)
    fake_input = tf.concat([grayscale, fake_colorized],
                           axis=-1)
    predictions = self.disc_model(fake_input)
    misleading_labels = tf.ones_like(predictions)

    g_loss = - self.loss_fn(misleading_labels, predictions)
    g_loss /= tf.cast(
        tf.reduce_prod(tf.shape(misleading_labels)[1:]),
        tf.float32)
    g_loss = tf.nn.compute_average_loss(g_loss,
        self.global_batch_size)
    l1_loss = tf.keras.losses.MeanAbsoluteError(
        reduction=tf.keras.losses.Reduction.NONE)(colorized,
        fake_colorized)
    l1_loss /= tf.cast(
        tf.reduce_prod(tf.shape(colorized)[1:]),
        tf.float32)
    l1_loss = tf.nn.compute_average_loss(l1_loss,
        self.global_batch_size)
    final_g_loss = g_loss + (l1_loss * self.reg_strength)

self.loss_fn is binary cross-entropy but in this case, it’s initialized without any reduction.
This loop is not behaving as expected because the losses are way off. Am I missing out on something?

Context: Are you in the same case as Custom training with tf.distribute.Strategy  |  TensorFlow Core 1 or is it something different?


Suggestions regarding a `tf.data` pipeline

Question:
I am currently using the RandAugment class from tf-models (from official.vision.beta.ops import augment). The RandAugment().distort(), however, does not allow batched inputs, and computation-wise it’s expensive as well (especially when you have more than two augmentation operations).
So, following suggestions from this guide 4, I wanted to be able to map RandAugment().distort() after my dataset is batched. Any workaround for that?
Here’s how I am building my input pipeline for now:
# Recommended is m=2, n=9
augmenter = augment.RandAugment(num_layers=3, magnitude=10)

dataset = load_dataset(filenames)
dataset = dataset.shuffle(batch_size*10)
dataset = dataset.map(augmenter.distort, num_parallel_calls=AUTO)

Context:
Yes the issue is that It seems to me that we have also duplicated OPS like e.g. cutout not batched in official.vision namespace  and batched in TFA 3.
These are the origins of the current status:

      github.com/tensorflow/addons

      Migrate AutoAugment and RandAugment to TensorFlow Addons. 2

        opened

        Mar 5, 2020

          closed

        May 28, 2020

          dynamicwebpaige

  Describe the feature and the current behavior/state.
RandAugment and AutoAugment are both policies for enhanced image preprocessing that are included in EfficientNet,...

    Feature Request
    help wanted
    image

      github.com/tensorflow/community

      Ask contribution to Tensorflow addons for general scope utils, loss, layers, ops 1

        opened

        Apr 1, 2020

          bhack

  As we have just refreshed the model repo as model garden I would enforce the contributions policies of generale use (or...


Question: How do you decide when to retrain your production models? Do you just always retrain them on a schedule, whether they need it or not, or do you monitor and evaluate your model’s performance in production?

Context:
One common practice I saw, is to collect a new (typically small) test set every few weeks (weekly is not uncommon) and use that to monitor if model performance is dropping consistently over time. If that is the case, it is typical to set a threshold on the drop. Once that drop threshold is reached, a new training set is compiled and new models are trained. Both old and new test sets can be used to compare new models with current production model.
I’ve also seen teams adopt a fixed retraining schedule, but only when they know from long experience that such drift does happen for their particular application.
There are some fancy methods for monitoring distribution drift but they can be deceiving as some drifts won’t actually affect the model performance.


What model(s) for a sequence of human poses?

Question:
Hi!
I would like to recognize a sequence of human poses, with a predefined timing. For example: recognize a tennis serve, a soccer kick, a ballet move, etc.
I have looked at pose similarity for single pose comparison here (https://blog.tensorflow.org/2018/07/move-mirror-ai-experiment-with-pose-estimation-tensorflow-js.html 4).
Is there a recommended model for a sequence of poses (LSTM?). I would also like to identify the deviation from ideal poses and timing (i.e. too early/late for this pose).
Thanks!

Context:
It’s a great quesiton, and I’d love to know the answer too!
I’m thinking multiple models would have to be used.
One is pose detection which captures a sequence of poses over time.
One is a sequence model, trained on sequences of poses to classify them as ‘good’ or ‘bad’ or some other label.
At runtime you then capture the sequence using the posenet, pull out the relevant parts of the skeleton, and feed that into the sequence model to get a classification.


Tell me your funny (SFW) Machine Learning stories?

Question:
Would love to hear funny stories about your ML implementations. What kind of bugs have you encountered?
One of my favorites – not sure if it’s true or not – was that a few years back the US Army wanted to build a computer vision model to detect camouflaged tanks. They got some data scientists to build a model, and these folks got to borrow a tank for a couple of days, drive it around the woods, and take lots of pictures. One day they did it without camo and labelled it. The next day they got the camo nets and did the same. They built a model with these pictures, and did everything right – holding back a portion for testing and validation. When they were done, their model was incredibly accurate. They had succeeded!
Then they went into the field to test it. And it failed, miserably. They couldn’t figure out why. Their test set and validation sets were properly selected and randomized. It should work.
And then somebody pointed out that the weather was sunny on day 1 (no camo), and cloudy on day 2 (with camo) , so instead of a camo detector, they had actually built a cloudy sky detector instead…

Context:
This reminds me of an actual experience I had a few years ago. I was training a reinforcement learning robot to navigate a (simulated) maze. This was for a competition at my university. The organizers provided us with an API where we would get a maze layout and the position of the robot and several exit points and “treasure” locations. Goal was to have robot leave the maze before a timer expired but the ranking was based on how much treasure you got.
After several hours of training, I got a robot which could navigate all the mazes that were generated by the  API, getting good exploration-exploitation balance. Then, we decided to train the pipeline so that instead of using the maze as provided by the API we used a rotation of it. Turns out the robot was getting stuck most of the time.
The reason? The maze generation algorithm that was provided in the API was biased to mazes that had long horizontal corridors and very short passages to next rows. So our robot was overfitting on this feature.
It was easy to fix and it turns out the organizers also fixed this in the generator for the actual competition. So only a few number of robots managed to score points during the actual event, as those teams put extra care towards preventing overfitting to the training data.


How to audit courses on Coursera for Free

Question:
We have lots of courses on Coursera, and we get lots of questions from folks that don’t want to sign in and pay to get a certificate, and just want to audit.
This is possible. It’s subtle, but possible – here are the details.
The audit option will give you the full content of the courses, but you will not earn the certificates for completing them.
Note the Coursera terminology. A specialization is a collection of courses. Specializations may not be audited. However, each of the individual courses within the specialization may be!
Below are links to each of these courses within their specialization.
To access them in audit, select the course, and then click on ‘enroll for free’.

Screen Shot 2021-02-22 at 5.26.44 PM866×392 43.8 KB

You’ll see a dialog like this. Important: Note the ‘Audit the Course’ link at the bottom. Do not select ‘Start Free Trial’.

Screen Shot 2021-02-22 at 5.28.31 PM660×578 76 KB

This will give you full access to the content.
Below are each of the specializations, and I’ve put direct links to the courses within them. Follow the above process with these links to access them at no cost.
TensorFlow: In Practice Specialization
Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning 6
Convolutional Neural Networks in TensorFlow 4
Natural Language Processing in TensorFlow 6
Sequences, Time Series and Prediction 7
TensorFlow: Data and Deployment Specialization
Browser-based Models with TensorFlow.js 2
Device-based Models with TensorFlow Lite 3
Data Pipelines with TensorFlow Data Services 3
Advanced Deployment Scenarios with TensorFlow 5
AI for Medicine Specialization
AI for Medical Diagnosis 2
AI for Medical Prognosis 3
AI For Medical Treatment 5
Natural Language Processing Specialization
Natural Language Processing with Classification and Vector Spaces 8
Natural Language Processing with Probabilistic Models 2
Natural Language Processing with Sequence Models 6
Natural Language Processing with Attention Models 3

Context:
Also the Advanced TensorFlow specialization:
TensorFlow: Advanced Techniques Specialization 6
Custom Models, Layers, and Loss Functions with TensorFlow 3
Custom and Distributed Training with TensorFlow 5
Advanced Computer Vision with TensorFlow 5
Generative Deep Learning with TensorFlow 6


Any experience (good or bad) using TF for unsupervised learning?

Question:
Having used many unsupervised learning algorithms in the past as part of my development pipeline, I was wondering about weather there are good implementations out there that are built on top of TensorFlow (I’ve seen a couple of k-means implementations in tutorial format, but not much more).
What tools other than TensorFlow do you use for your unsupervised learning needs?

Context:
I have been using TensorFlow for coding up a number of different self-supervised models for vision and the experience have been great (and easy). Feel free to take a look into the following minimal implementations of popular self-supervised methods for vision:

SimCLR 6
SwAV 5
SimSiam 2

Sorry, could not post links because the forum does not yet allow it.


Question: Great book suggestions to learn TensorFlow

Context:
Let me start with a very good one if you are starting with Machine Learning and is already a developer:
AI and Machine Learning for Coders PXL_20201229_1625560064032×3024 1.85 MB
It’s very easy to follow and shows some good use cases and a lot of hands on code to try.


What OS do you primarily use TensorFlow on?

Question: What operating system do you use TensorFlow on? Linux MacOS Windows Other30votersShow results

Context: I’d add Colab as an option (or maybe the Browser). I know it’s not a OS but it’s my main IDE as of these days


Official #MadeWithTFJS Show & Tell inspiration thread

Question:
Once per quarter we meet with several members from the TensorFlow.js community to learn more about what amazing projects they have created. This thread is the one stop place to see the latest interviews to get inspiration of what is possible using Machine Learning in JavaScript across front end (browser), back end (Node.js), React Native (native app), Electron (desktop), and even IOT (Raspberry Pi via Node). Check back regularly!
To kick things off, here is our first video interview:
Enjoying the show with Gant Laborde who explains how he solved a problem when presenting digitally to an audience where he was unable to know if they were interested in the content being presented. Learn how Gant created an innovative,  real-time, and scalable system to better understand his audience using machine learning in the browser using TensorFlow.js.

Context: Real-time semantic segmentation in the browser with Hugo Zanini - a Python developer who was looking to use the latest cutting edge research from the TensorFlow community in the browser using JavaScript. Join us as Hugo takes us through his learning experiences in using SavedModels in an efficient way in JavaScript directly enabling you to get the reach and scale of the web for your new research.


Question:
Got a cool project? Share and show off your work.
Feel free to share links to demos, GitHub and posts for your project. You can also submit your project 13 to the TensorFlow Community Spotlight program for the chance to be featured on the TensorFlow Twitter handle.

Context:
I worked on various Pre-trained Machine Learning Models on Raspberry Pi. These are computer vision models (Inception and Mobilenets) provided by the Google Coral team.
Though they have provided examples to run these models using sample scripts, I thought it would be a nice idea to make a simple tool using Python & Web dev which can run these 20+ models without having to stop and start the Python script every time you need to test a different model. Further,  the tool takes care of Object Detection and Image classification methods dynamically and provides output accordingly.
To simplify the installation process, I have written a bash script using which anyone can configure his/her Raspberry Pi in all respects to run this project. The script automatically installs Tensorflow Lite, OpenCV, all the models and source code of this project on a Raspberry Pi. Basically, a beginner can start seeing the output without having to see the code or worry about it.
I named the tool ‘Model Garden’ and I think it will be useful for students / hobbyists to get started with Machine Learning on a Raspberry Pi or atleast have a feel of these wonderful models without much hassle.
Check this on Github:-
jiteshsaini/model_garden


Implementing “Augmenting convolutional networks with attention-based aggregation”

Question:
In my latest keras example I minimally implement “Augmenting Convolutional networks with attention-based aggregation” by Touvron et. al.
The main idea is to use a non-pyramidal convnet architecture and to swap the pooling layer with a transformer block. The transformer block acts like a cross-attention layer that helps in attending to feature maps that are useful for a classification decision.
The attention-maps from the transformer block helps in the interpretability of the model. It let’s us know which part (patch) of the image is the model really focused on when making a classificaiton decision.

Link to the tutorial: Augmenting convnets with aggregated attention
@Ritwik_Raha, @Devjyoti_Chakraborty and I have built a Hugging Face demo around this example for all of you to try. In the demo we use a model that was trained on the imagenette dataset.

image1732×886 126 KB

Link to the demo: Augmenting CNNs with attention-based aggregation - a Hugging Face Space by keras-io 2
I would like to thank JarvisLabs.ai for providing me with GPU credits for this project.

Context:
Just tried, amazing.

image1496×748 68.1 KB


Question:
An article that briefly recaps all the challenges faced solving half of the advent of code 2021 challenges in pure TensorFlow and allows you to browse them easily.

      P. Galeone's blog

Wrap up of Advent of Code 2021 in pure TensorFlow 8

  A wrap up of my solutions to the Advent of Code 2021 puzzles in pure TensorFlow

Context:
This is very interesting!
I thought it was already challenge to solve all the problems with regular Python!


New, clean implementation of Faster R-CNN in both TensorFlow 2/Keras and PyTorch

Question:
Hi everyone,
I recently put the finishing touches on my Faster R-CNN self-learning exercise. My goal was to replicate the model from scratch using only the paper. That was a bit ambitious and I had to eventually relent and peek at some existing implementations to understand a few things the paper is unclear on. The repo is here: GitHub - trzy/FasterRCNN: Clean and readable implementations of Faster R-CNN in PyTorch and TensorFlow 2 with Keras. 3
I wrote both a PyTorch and a TensorFlow implementation. I’d like to think they are pretty clean, readable, and easy to use. I also documented some of my struggles and takeaways in the README.md file.
One thing that continues to bother me is the need for an additional tf.stop_gradient() in the regression loss functions surrounding a tf.less statement. The function itself is differentiable. The PyTorch version doesn’t need this. I might make a post about it on one of the other sub-forums because I stumbled upon the solution by accident. Without the explicit stop_gradient, the model still learns, but achieves significantly lower precision. Would love to learn about how others would approach debugging such an issue.
Thanks,
Bart

Context: @Bart great. You made a lot of effort out there, starred. A small request, in your read-me there’s a lot of development details which can be separated as another .md.  In this way, the front read-me.md can give more top-level highlights for example how-to-reproduce, how-to-fine-tune- or how-to-train-from-scratch-on-custom-data, etc.


Question:
I was checking the grad-cam of a pure cnn and a hybrid model (cnn+swin_transformer). Now, after passing an intermediate layer from CNN to Swin-transformer, it looks like the transformer blocks are able to refine the feature activation globally across the relevant object; unlike CNN which is more interested to operate locally.

(left: input,  – middle: CNN, –  right: CNN + Transformer / Hybrid).
Code example: TF: Hybrid EfficientNet Swin-Transformer : GradCAM | Kaggle 4

Context:
Nice, It could be interesting to visualize also:

      GitHub

GitHub - google-research/vmoe

  Contribute to google-research/vmoe development by creating an account on GitHub.


Question:
ViTs are data hungry, pretraining a ViT on a large-sized dataset like JFT300M and fine-tuning it on medium-sized datasets (like ImageNet) is the only way to beat state-of-the-art Convolutional Neural Network models.
The self-attention layer of ViT lacks locality inductive bias (the notion that image pixels are locally correlated and that their correlation maps are translation-invariant). This is the reason why ViTs need more data. On the other hand, CNNs look at images through spatial sliding windows, which helps them get better results with smaller datasets.
In my latest keras example I minimally implement the academic paper Vision Transformer for Small-Size Datasets. Here the authors set out to tackle the problem of locality inductive bias in ViTs by introducing two novel ideas:

Shifted Patch Tokenization (SPT): A tokenization scheme which allows for a greater receptive field for the transformer.

image832×400 94.6 KB

Locality Self Attention (LSA): A tweaked version of the multi head self attention mechanism. Applying a diagonal mask and a learnable temperature quotient to the regular self attention, we get our LSA. Inheriting the tf.keras.layers.MultiHeadAttention and tweaking the API was my greatest win while implementing LSA.

image1200×709 63.5 KB

Tutorial: Train a Vision Transformer on small datasets 9

Context: Amazing    Thank you


Question:
Hello Community!
I’m sharing a personal project of mine, which was to rewrite ResNet-RS models from TPUEstimator to Tensorflow/Keras.

      GitHub

GitHub - sebastian-sz/resnet-rs-keras: ResNet-RS models rewritten in... 49

  ResNet-RS models rewritten in Tensorflow / Keras functional API. - GitHub - sebastian-sz/resnet-rs-keras: ResNet-RS models rewritten in Tensorflow / Keras functional API.

Features:
 Automatic weights download.
 Transfer learning possible.
 pip install directly from GitHub.
 keras.applications like usage.
 Use like any other Tensorflow/Keras model!
Other links:

Original repository 5
Arxiv Link

Let me know what you think!

Context: Nice work, I really appreciate the “thoroughness”, especially TFLite support and Docker


Implementing DeepMind’s new Perceiver Model

Question:
I am glad to present an implementation of DeepMind’s new “Perceiver: General Perception with Iterative Attention” Model which builds on top of Transformers but solves the quadratic scaling problem without making any assumptions of the data like the previous approaches in TensorFlow. This means you can use the same model on images, audio, videos, etc! This model also achieves state-of-the-art for some tasks!
Find it here:

      github.com

Rishit-dagli/Perceiver 71

  Implementation of Perceiver, General Perception with Iterative Attention in TensorFlow

Context:
Nice, we have also a tutorial/example for image classification with Perceiver on the Keras doc website

      keras.io

Keras documentation: Image Classification with Perceiver 74

If you have any feedback/PR to improve the tutorial it is very appreciated.


Question:
@deep-diver and I have worked on an MLOps project for the past couple of months. It shows how “Continuous Adaptation for ML System to Data Changes” can be done by building/interconnecting two separate pipelines (note this project is done in TFX and various GCP services).

image1600×799 125 KB

We have written a blog post about some of the internal implementation details, and it is published on TensorFlow Blog. Please find it here:

      blog.tensorflow.org

Continuous Adaptation for Machine Learning System to Data Changes 4

  Learn how ML models can continuously adapt as the world changes, avoid issues, and take advantage of new realities in this guest blog post.

Also, we have open-sourced all the materials to reproduce this project including in-depth explanations within a set of Jupyter notebooks. You can find the repo here

      GitHub

GitHub -... 1

  Contribute to deep-diver/Continuous-Adaptation-for-Machine-Learning-System-to-Data-Changes development by creating an account on GitHub.

@Robert_Crowe, huge thanks for your help on this one.
Thanks for your valuable time to read this and we hope this will be helpful

Context:
Thanks it is a nice tutorial, It could be interesting one day to expand this to cover:

some state of the art continual learning approaches instead of retraining the whole model.
to handle the drift in an openset/openworld context 2 instead of just a misclassification threshold in the closed set classes.


I implemented Transformer in Transformer in TensorFlow

Question:
I implemented the very recent NeurIPS 21 paper Transformer in Transformer in TensorFlow which uses attention inside local patches essentially using pixel level attention paired with patch level attention. This also achieves SoTA performance on image classification beating ViT and DeiT with similar computational cost.

      GitHub

GitHub - Rishit-dagli/Transformer-in-Transformer: An Implementation of... 11

  An Implementation of Transformer in Transformer for image classification, attention inside local patches - GitHub - Rishit-dagli/Transformer-in-Transformer: An Implementation of Transformer in Tran...

Context:
github.com/keras-team/keras-io

      Update an example on transformer_in_transformer 4

      keras-team:master ← czy00000:master

        opened

        Nov 6, 2021

          czy00000

          +357
          -0

    sove the problem of this PR #687


Masked Autoencoders for self-supervised pretraining of images

Question:
Hi folks,
I hope you are doing well. Since last year, the computer vision community experienced a boom in self-supervised pertaining methods for images. While most of these methods share common recipes (augmentation, projection head, LR schedules, etc.)
reconstruction-based pertaining methods differ from them and make the process simpler and more scalable. Such a method is Masked Autoencoding released a couple of days ago from FAIR. Today, we (@ariG23498 and myself) are happy to share a pure TensorFlow implementation of the method along with commentary and promising results:
Masked image modeling with Autoencoders 12.
It is along similar lines to BERT’s pretraining objective: masked language modeling.
Some advantages of this method:

Does not rely upon sophisticated augmentation transforms
Easy to implement (barring a few nuts and bolts)
Quite faster pre-training
Implicit handling of representation collapse
On par with SoTA for self-supervision in the field of computer vision

I hope you folks will find the article useful and as always, we are happy to answer questions.

Context:
Sayak_Paul:

,

Great work on this Sayak, this will definitely be useful for many.
Small thing, but the keras page is future dated. But this is so cool it might as well be in the future


Question:
Have you ever wondered how to convert your dark images into better photos? Now you can do it in one second, with the help of the Zero-DCE model. The TF-Lite model is available on TensorFlow Hub. Now you can effortlessly deploy this Deep Learning model on your edge devices to get amazing images as output.
Thanks to Soumik Rakshit 1 for building the Zero-DCE model, Sayak Paul 1 and Tulasi Ram Laghumavarapu 1 for guiding me while contributing to TensorFlow Hub.
TensorFlow Hub Link: TensorFlow Hub 1

References

Zero-DCE paper link: https://arxiv.org/pdf/2001.06826.pdf

Zero-DCE Original Repository: GitHub - soumik12345/Zero-DCE: Pytorch implementation of Zero-Reference Deep Curve Estimation for Low-Light Image Enhancement

Zero-DCE Keras Example: Zero-DCE for low-light image enhancement 1

Zero-DCE TF-Lite Repository: GitHub - sayannath/Zero-DCE-TFLite: Conversion of TF-Lite model from ZERO-DCE model 4

PS: My first contribution to TensorFlow Hub

Context:
Congrats Sayan!
Very nice work overall! Mainly the TFHub model publishing!


Question:
Neural Style Transfer as proposed by Gatys et. al. was a slow and iterative method that could not transfer style in real time. With Adaptive Instance Normalization 1 we achieve arbitrary style transfer in real time.
Our (with @Ritwik_Raha) Keras blog post on AdaIN got published.
Link: Neural Style Transfer with AdaIN 1
The post is also accompanyed by a hugging face demo for you all to try the models out.
Hugging face demo: Neural Style Transfer using AdaIN - a Hugging Face Space by ariG23498 1
Hope this example turns out to be a good addition to the community.

Results

Style Transfer Image546×1661 1.21 MB

Context:
Nice work Ari!!
Why don’t you publish these models also on TensorFlow Hub?


Question:
Hi folks,Continuous integration and deployment (CI/CD) is a common topic of discussion when it comes to DevOps. No wonder why it has also become so for MLOps. With MLOps though, we have another piece of continuity - continuous re-training and evaluation.
In our latest two-part article from the GCP blog, @deep-diver and I dive deep into incorporating CI/CD for ML with TensorFlow, TFX, and Vertex AI along with other services from GCP. We take the scenario where we need to incorporate code changes (be it for better training techniques or better model architectures) for an ML system and perform CI/CD in a meaningful manner. Below are the links:

Model training as a CI/CD system (Part I): Code 14 | Blog Post 27

Model training as a CI/CD system (Part II): Code 2 | Blog Post 6

Happy to answer q’s.

Context:
@Sayak_Paul
CI/CD tool(cloud build or github action here) always starts from clean state with fresh container. That means there is no existing pipeline, but you can do update if you are using a dedicated stateful server.


Question:
Adaptive Instance Normalization 7 was a great read. Here the authors argue that instance normalization is indeed style normalization.
With that in mind, they provide a faster and more versatile approach to neural style transfer.
My take: GitHub - ariG23498/AdaIN-TF: Minimal Implementation of AdaIN with TensorFlow 30

Context:
Built a hugging face space for this project.
Link: Neural Style Transfer using AdaIN - a Hugging Face Space by ariG23498 3
Worked on it with @Ritwik_Raha.


Question:
Hi folks,
I am pleased to share my latest blog post with you: Distributed Training in TensorFlow with AI Platform & Docker.

      Sayak Paul – 6 Apr 21

Distributed Training in TensorFlow with AI Platform & Docker 17

Training a model using distributed training with AI Platform and Docker.

It will walk you through the steps of running distributed training in TensorFlow with AI Platform training jobs and Docker. Below, I explain the motivation behind this blog post:
If you are conducting large-scale training it is likely that you are using a powerful remote machine via SSH access. So, even if you are not using Jupyter Notebooks, problems like SSH pipe breakage, network teardown, etc. can easily occur. Consider using a powerful virtual machine on Cloud as your remote. The problem gets far worse when there’s a connection loss but you somehow forget to turn off that virtual machine to stop consuming its resources. You get billed for practically nothing when the breakdown happens until and unless you have set up some amount of alerts and fault tolerance.
To resolve these kinds of problems, we would want to have the following things in the pipeline:

A training workflow that is fully managed by a secure and reliable service with high availability.
The service should automatically provision and de-provision the resources we would ask it to configure allowing us to only get charged for what’s been truly consumed.
The service should also be very flexible. It must not introduce too much technical debt into our existing pipelines.

Happy to address any feedback.

Context: Nice, another solution that we have is Tensorflow-cloud 11


Question:
I contributed this collection containing 6 different ConvMixer models that were pre-trained on the ImageNet-1K dataset available for fine-tuning as well as image classification. Further, the models are also accompanied with a tutorial to help you get started in <5 minutes.
ConvMixer is a simple model that uses only standard convolutions to achieve the mixing steps. Despite its simplicity, ConvMixer outperforms ViT and MLP-Mixer. ConvMixer relies directly on patches as input, separates the mixing of spatial and channel dimensions and maintains equal size and resolution throughout the network.
https://tfhub.dev/rishit-dagli/collections/convmixer 8
The associated GitHub repo could be found here:

      github.com

GitHub - Rishit-dagli/ConvMixer-torch2tf: This repository hosts code for... 7

  This repository hosts code for converting the original ConvMixer models (PyTorch) to TensorFlow. - GitHub - Rishit-dagli/ConvMixer-torch2tf: This repository hosts code for converting the original C...

You might want to take a look at a ConvMixer implementation by @Sayak_Paul here 2 and by @sayannath235 here 3.

Context:
This is very cool Rishit!
Thanks for contributing to TFHub and helping the community have access newer models!


Question:
Combining the benefits of convolutions (for spatial relationships) and transformers (for global relationships) is an emerging research trend in computer vision. In my latest example, I present the MobileViT architecture (Mehta et al. 1) that presents a simple yet unique way to reap benefits of the two.
With about a million parameters, it achieves a top-1 accuracy of ~86% on the tf_flowers dataset on 256x256 resolution. Furthermore, the training recipes are simple and the model runs efficiently on mobile devices (which is atypical for transformer-based models).

      keras.io

Keras documentation: MobileViT: A mobile-friendly Transformer-based model for... 28

Context: That’s amazing!  Great work as always


Question:
A “point cloud” is an important type of data structure for storing geometric shape data. Due to its irregular format, it’s often transformed into regular 3D voxel grids or collections of images before being used in deep learning applications, a step that makes the data unnecessarily large.
In our latest example (Soumik and myself), we present PointNet (from 2017) solves this problem by directly consuming point clouds, respecting the permutation-invariance property of the point data. Additionally, we’re working on a comprehensive repository on performing point cloud segmentation at scale with full TPU support.

image560×558 96.6 KB

Keras example: Point cloud segmentation with PointNet 10

GitHub repo: https://git.io/Jidna 5

Context:
This is great!
Nice work!


New Keras Example: Image classification with Swin Transformers

Question:
Here goes my next Keras Example all about implementing Swin Transformers, a general-purpose backbone for computer vision. The Swin Transformer architecture for image classification – a Transformer-based vision model that uses local self-attention as a way to make self-attention on images linear in complexity. I go on to demonstrate using this for image classification on CIFAR-100.

      keras.io

Keras documentation: Image classification with Swin Transformers 51

Context: PS: After your wonderful suggestion, @lgusm , I am already in works to publish the trained model on TF Hub.


Rock, paper, scissors game powered by MobileNetV2

Question:
I have recently finalized my project and decided to share with you
It’s rock, papar, scissors game powered by the MobileNetV2 model  and deployed completely server-less with Tensorflow.js:

      romaglushko.com

Rock, Paper, Scissors Game - Lab by Roman Glushko 13

  Rock, paper, scissors online game powered by Machine Learning

There is a demo of the game where you can try it and the full story how I built the project. Hope you will have a great time checking it out

Context:
Welcome to the forum and thank you for sharing your TensorFlow.js demo! Always great to see what folk are up to.  I actually did something similar a few years back (but was not TensorFlow.js) where I recorded a GIF of myself and was able to make it look like you were playing a real person - you may be able to update your version to do something similar too:
Rock Paper Scissors - Machine Learning Style using Tensor Flow

You can see in the bottom left the live view in the last second when you show your hands, and the large GIF is the “computer”. My version here used websockets to transmit the final frame to web server for classification which is certainly less elegant than a pure TensorFlow.js solution, but it did not exist back when I made this
Look forward to seeing how your project (or future projects) evolve! Thanks for being part of the #madeWithTFJS community!


A new notebook: Structured Data Classification using TensorFlow Decision Forests

Question:
Hi everyone,
As part of Kaggle’s " Tabular Playground Series - Sep 2021", I created a notebook using TensorFlow Decission Forests.
If you’re interested, check it out please and let me know if you have any ideas on how to make it better and enhance it.

      colab.research.google.com

Google Colaboratory 103

Regards,
Fadi Badine

Context: Another super cool example! Thank you @Fadi_Badine!


Finding similar questions via contrastive learning using QA dataset

Question:
Hi, there.
I developed a model to find similar questions or answers via contrastive learning, and I think I got a good result in a new way. So I want to share my codes and results here.
The idea is very simple; similar questions should be answered similarly. So I built a model that encodes question texts and finds appropriate answers in a contrastive objective. After the training, I could find similar questions using the trained encoder.

      github.com

GitHub - jeongukjae/question-similarity: Find similar questions via contrastive... 3

  Find similar questions via contrastive learning. Contribute to jeongukjae/question-similarity development by creating an account on GitHub.

Context: @Divvya_Saxena I removed the help_request tag because this post is not for requesting help. But thanks for updating the other tags!


Learning Machine Learning in 30+ Notebooks (TensorFlow and other ML tools included)

Question:
I am releasing a comprehensive repository containing 30+ notebooks on Python programming, data manipulation, data analysis, data visualization, data cleaning, classical machine learning, Computer Vision, and Natural Language Processing(NLP).

git_cover1280×640 127 KB

Here is the link 33 for the repo. The easiest way of reviewing the notebooks is through Nbviewer 4.
For Deep Learning with TensorFlow specific repo, here is the link 9. And to review the notebooks here 4.

Context: Thanks for sharing Jean!


Reminder! TensorFlow Community Spotlight Program

Question:
Are you doing great things with TensorFlow? If you have a cool TensorFlow project you’d like us to review for a chance to be featured on our #TFCommunitySpotlight  5 channel and win some TF swag, you can submit it here: goo.gle/tfcs 8
Check out our most recent winner’s project @Sayak_Paul @ goo.gle/3AxVn5Y 9

      twitter.com

TensorFlow (TensorFlow) 5

  🏅Congratulations to #TFCommunitySpotlight winner, Sayak Paul (ML GDE)!

Sayak’s project provides a systematic way to compress bigger models into smaller ones allowing developers to serve them at lower costs. Great job!

Check it out → https://t.co/R4zeX6oOOn

  12:07 PM - 19 Aug 2021

      128

      23

Context: I didn’t know that it received the award :o I thought I’d get tagged. But anyway, thank you!


New GCP Blog: Dual Deployments on Vertex AI

Question:
@deep-diver and I have been constantly working on MLOps projects, and we want to share one of our latest works with you guys, “Dual Deployments on Vertex AI”. We leverage several components from the ML tooling provided by Google such as TensorFlow, TFX, Vertex AI, Cloud Build, and so on.
Dual Deployments is a common machine learning design pattern.

image1102×938 123 KB

As described in the blog post, it can be applied to two scenarios of online/offline predictions and layered predictions.
In this blog post, we introduce two different approaches on how to write a machine learning pipeline to realize the dual deployment pattern.

TFX + custom model based approach
: DenseNet for cloud and MobileNet v3 for mobile deployments.

KFP + GCP’s AutoML based approach
: AutoML for cloud and AutoML Edge for mobile deployments.

In both cases, you can find out how custom components can be written including

At the time of writing the blog post, TFX didn’t support uploading/hosting trained models on Vertex AI, so we wrote ones ourselves.
For mobile deployment, we wrote a custom component to publish the TFLite model to Firebase ML.

If you find this brief description interesting, please find more information:

GCP Blog Post: Dual deployments on Vertex AI | Google Cloud Blog 3

GitHub Repo: https://github.com/sayakpaul/Dual-Deployments-on-Vertex-AI 1

Context:
Congrats Sayak and Chansung for the detailed post!!
The TF community is just amazing!!!


Reducing the parameter size of LaBSE(language-agnostic BERT Sentence Embedding) for practical usage

Question:
To get good quality language-agnostic sentence embeddings, LaBSE is a good choice. But due to the parameter size(Bert-base size, but #param is 471M), it is hard to fine-tune/deploy appropriately in a small GPU/machine.
So I applied the method of the paper “Load What You Need: Smaller Versions of Multilingual BERT” to get the smaller version of LaBSE, and I can reduce LaBSE’s parameters to 47% without a big performance drop using TF-hub and tensorflow/models.
GitHub: https://github.com/jeongukjae/smaller-labse 15

Relative Links:

Language-agnostic BERT Sentence Embedding(LaBSE) (Paper: [2007.01852] Language-agnostic BERT Sentence Embedding, TF-hub:TensorFlow Hub 1)
Load What You Need: Smaller Versions of Multilingual BERT (Paper: [2010.05609] Load What You Need: Smaller Versions of Multilingual BERT 1, GitHub: https://github.com/Geotrend-research/smaller-transformers 1)

Context:
Nice work Jeon!!
Does the preprocessing model still works with your model? or is there still a need for it?
Did you think about publishing this to TFHub too?


Question: tensorflow modifies the input channel of the pre-trained model

Context:
Hi Weizhi.
Can you explain in more details what issue are you facing? maybe with some code.


Implementing Fastformer: Additive Attention Can Be All You Need

Question:
I am glad to present my implementation of the “Fastformer: Additive Attention Can Be All You Need” paper.
This is a Transformer variant based on additive attention that can handle long sequences efficiently with linear complexity. Fastformer is much more efficient than many existing Transformer models and can meanwhile achieve comparable or even better long text modeling performance.

      github.com

GitHub - Rishit-dagli/Fast-Transformer: An implementation of Fastformer:... 26

  An implementation of Fastformer: Additive Attention Can Be All You Need in TensorFlow - GitHub - Rishit-dagli/Fast-Transformer: An implementation of Fastformer: Additive Attention Can Be All You Ne...

Context:
Nice work!
If you have the trained model, maybe you could also publish it on Tensorflow Hub 3


Trying to get TFJS better supported at Edge Impulse

Question:
Edgeimpulse.com 2 tinyML Machine Learning supports exports to Tensorflow, TensorflowLite, TensorflowMicro but not TensorflowJs. It can easily be converted from one of the other formats but typically takes a python script which is not Javascript.
Perhaps a few people could “like” the following Feature Request at EdgeImpulse.com 1 to increase its chances of adoption.

      Edge Impulse – 5 Aug 21

Feature Request: export TensorflowJS 3

  Could Edge Impulse please fully support all versions of Tensorflow specifically by adding dashboard exported support for TensorflowJs?  Would show a zipped model.json with binary shard files, preferably float32 and also with int8 quantization. ...

Context:
So it looks like Edge Impulse will not be helping with exporting to TFJS.
Anyone any opinions on how to convert from Tensorflow saved model to TensorflowJs layers model.  I used to do it all the time but my code doesn’t seem to work anymore. Anyone got uptodate conversion examples and installation code.
I used to have several steps full automated on this github to take a model.json to several other forms, but I dont even thing the instalation is working anymore.
Any suggestions?

      github.com

GitHub - hpssjellis/Gitpod-auto-tensorflowJS-to-arduino 1

  Contribute to hpssjellis/Gitpod-auto-tensorflowJS-to-arduino development by creating an account on GitHub.

‘’’
pip install tf-nightly
pip install tensorflowjs
pip install netron “dask[delayed]”
tensorflowjs_converter --input_format=tfjs_layers_model --output_format=keras_saved_model ./model.json ./
tflite_convert --keras_model_file ./ --output_file ./model.tflite
xxd -i model.tflite model.h
‘’’


Question:
Sentence 1: Sourav Ganguly is the greatest captain in BCCI.
Sentence 2: Ricky Ponting is the greatest captain in Cricket Australia.
Do these two sentences contradict/entail each other or are they neutral? In NLP, this problem is known as textual entailment and is a part of the GLUE benchmark for language understanding.
On social media platforms, to better curate and moderate content, we often need to utilize multiple sources of data to understand their semantic behavior. This is where multimodal entailment can be useful. In my latest post, I introduce the basics of this topic and present a set of baseline models for the Multimodal Entailment dataset recently introduced by Google. Some recipes include “modality dropout”, cross-attention, and class-imbalance mitigation.

Blog post: Multimodal entailment 4

Code: https://git.io/JR0HU 4

Fun fact: This marks the 100th example on keras.io 1.

Context:
Thanking @markdaoust, @lgusm, and @jbgordon for the amazing tutorial on

      TensorFlow

Solve GLUE tasks using BERT on TPU  |  Text  |  TensorFlow 2

My post on multimodal entailment uses a fair bit of code from that post (of course with due citation). With that, I wanted to take the opportunity to thank you, folks, for the tutorial since it DEFINITELY helps in solving GLUE tasks more accessible and readily approachable.


Question:
Our new Keras example just got published in Keras.
Link: 3D volumetric rendering with NeRF 23
In this joint venture with Ritwik Raha 5, we present a minimal implementation of the research paper NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis by Ben Mildenhall et. al. The authors have proposed an ingenious way to synthesize novel views of a scene by modelling the volumetric scene function through a neural network. We try making concepts like 3D volumetric rendering and ray tracing as visual as possible.
We would like to thank @Sayak_Paul for his thorough review of the first draft. We also want to acknowledge @fchollet  for his guidance through and through.

The GIFs in the example are made with manim 5. We like how the animations have turned out to be.

manim854×480 2.05 MB

Context:
This looks very interesting.
Sorry for my ignorance but after you train the model, can you apply to new data easily?


Involution: Inverting the Inherence of Convolution for Visual Recognition

Question:
Where convolutions have been the doing great at what it does, involution symmetrically inverts the inherent properties of convolutions. Where convs are spatial-agnostic and channel-specific operations, invs are spatial-specific and channel-agnostic operations.
My take on Involutions: GitHub - ariG23498/involution-tf: TensorFlow implementation of involution. 15
Here one can find the Involution Layer which has all the necessary code to build the kernel dynamically and also apply it on the input feature space. One can also pick the code up and apply the layer to any tf based architecture.

Context:
Hey Folks,
I have also had the opportunity to write on this topics as a Keras example.
Link: Involutional neural networks 4
Any feedback is welcome.


Knowledge distillation with “Function Matching”

Question:
Hi folks,
Today I am pleased to open-source the code for implementing the recipes from Knowledge distillation: A good teacher is patient and consistent 11 (function matching) and reproducing their results on three benchmark datasets: Pet37, Flowers102, and Food101.
Importance: The importance of knowledge distillation lies in its practical usefulness. With the recipes from “function matching”, we can now perform knowledge distillation using a principled approach yielding student models that can actually match the performance of their teacher models. This essentially allows us to compress bigger models into (much) smaller ones thereby reducing storage costs and improving inference speed.
Some features of the repository I wanted to highlight:

The code is provided as Kaggle Kernel Notebooks to allow the usage of free TPU v3-8 hardware. This is important because the training schedules are comparatively longer.
There’s a notebook 1 on distributed hyperparameter tuning and it’s often not included in the public release of an implementation.
For reproducibility and convenience, I have provided pre-trained models and TFRecords for all the datasets I used.

Here’s a link to the repository

      github.com

GitHub - sayakpaul/FunMatch-Distillation: TF2 implementation of knowledge... 10

  TF2 implementation of knowledge distillation using the "function matching" hypothesis from https://arxiv.org/abs/2106.05237. - GitHub - sayakpaul/FunMatch-Distillation: TF2 implementation...

I’d like to sincerely thank Lucas Beyer (first author of the paper) for providing crucial feedback on the earlier implementations, ML-GDE program for the GCP support, and TRC for providing TPU access. For any questions, either create an issue in the repository directly or email me.
Thank you for reading!

Context: Very exciting Sayak, thanks!


Question:
Vector-Quantized VAEs were proposed in 2017. Since its inception, it has pushed the field of high-quality image generation to a great extent. Its recipes like discrete latent space optimization, codebook sampling, etc. have gone to later become essential blocks for modern models like VQ-GAN, DALL-E, etc.
In my latest Keras example, I present an implementation VQ-VAEs including the subsequent PixelCNN part for image reconstruction and generation. I’ve included crucial pieces of visualizations as well to make it fun and interesting.

image2916×1574 411 KB

Here is the link to my example:

      keras.io

Keras documentation: Vector-Quantized Variational Autoencoders 12

Context:
Well done Sayak!
always great content!


Clarifications on parsing arguments in a TFX pipeline

Question:
I have been building my muscle memory for MLOps and the progress has been good so far. Thanks to Coursera’s Specialization, ML Design Patterns book, and Vertex AI’s neat examples.
I wanted to build a simple Vertex AI pipeline that should train a custom model and deploy it. TFX pipelines seemed like a way easier choice for this than KFP pipelines.
I am now referring to this stock example:

      colab.research.google.com

Google Colaboratory 3

I see loads of argument parsing here and there, especially in the model building utilities. For reference, here’s a snippet that creates ExampleGen and Trainer in the initial TFX pipeline:
# Brings data into the pipeline.
example_gen = tfx.components.CsvExampleGen(input_base=data_root)

# Uses user-provided Python function that trains a model.
trainer = tfx.components.Trainer(
    module_file=module_file,
    examples=example_gen.outputs['examples'],
    train_args=tfx.proto.TrainArgs(num_steps=100),
    eval_args=tfx.proto.EvalArgs(num_steps=5))

The run_fn only takes fn_args as its arguments. I am wondering how the arguments passed and mapped inside penguin_trainer.py?
I will be grateful for an elaborate answer.

Context: I guess @Robert_Crowe might be able to help here


Question:
How does a commoner train a Transformers-based model on small and medium datasets like CIFAR-10, ImageNet-1k and still attain competition results? What if they don’t have the luxury of using a modern GPU cluster or TPUs?
You use Compact Convolutional Transformers (CCT). In this example, I walk you through the concept of CCTs and also present their implementation in Keras demonstrating their performance on CIFAR-10:

      keras.io

Keras documentation: Compact Convolutional Transformers 45

A traditional ViT model would take about 4 Million parameters to get to 78% on CIFAR-10 with 100 epochs. CCTs would take 30 epoch and 0.4 Million parameters to get there

Context: Well done Sayak!!! you’re on fire!!


Question:
Hello Community
I have just developed an algorithm (I can say a family of algorithms) which have as performance a fast convergence while maintaining the generalization
I ask you for any help and advice
I want to join a company as a researcher in the field of artificial intelligence. having access to very expensive hardware (like GPUs) and more…
Here are the results of one of my algorithms in MNIST and IMBD data.( conduct on personal computer)

sincerely

Context:
Hi there,
This seems interesting. I do observe, however, that certainly for a low number of epochs,  your algorithm has lower accuracy compared to the industry standards. Perhaps your approach has some other benefits that are not represented on these graphs? (time wise?)
Cheers,
Timo