Categories
Misc

Batch the calculation to resize the image

Hi,

Could anyone please give me an example of how to batch the calculation when using tf.image.resize? Resizing all the images (20000) in my dataset at once crashes my system. I’m trying to upscale my images. I couldn’t find the documentation or examples for it.

submitted by /u/aark91
[visit reddit] [comments]

Categories
Misc

Learn TensorFlow

I am a bit new to the TensorFlow. I have following questions

  1. How to select which version to use.
  2. How different are the two versions.
  3. what could be the best way to learn TensorFlow( are learning TF1 and learning TF2 completely different things?)

I would really appreciate any help. Thank you

submitted by /u/Pranavkulkarni08
[visit reddit] [comments]

Categories
Misc

deeplab implementation, not working

Hello,

My code :

https://gofile.io/d/mTlna9

i’m beginner with tensorflow, and i’m trying to make a deeplab implementation in tensorflow 2.

I run my notebook and i don’t have error during the fit when i use run_eagerly = True, but with this option the loss stay at nan

And when i don’t use run_eagerly, i have this error :

————————————————————————— ValueError Traceback (most recent call last) <ipython-input-16-f5ffc11fb617> in <module> 133 dataset_entrain = dataset_entrain.shuffle(buffer_size=10).batch(batch_size=1) 134 –> 135 model.fit(dataset_entrain, epochs=10, callbacks=[ModelCheckpoint(‘policy_seg_{epoch}.h5’)]) 136 137 ~/envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing) 1098 _r=1): 1099 callbacks.on_train_batch_begin(step) -> 1100 tmp_logs = self.train_function(iterator) 1101 if data_handler.should_sync: 1102 context.async_wait() ~/envs/project/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in __call__(self, *args, **kwds) 826 tracing_count = self.experimental_get_tracing_count() 827 with trace.Trace(self._name) as tm: –> 828 result = self._call(*args, **kwds) 829 compiler = “xla” if self._experimental_compile else “nonXla” 830 new_tracing_count = self.experimental_get_tracing_count() ~/envs/project/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds) 886 # Lifting succeeded, so variables are initialized and we can run the 887 # stateless function. –> 888 return self._stateless_fn(*args, **kwds) 889 else: 890 _, _, _, filtered_flat_args = ~/envs/project/lib/python3.8/site-packages/tensorflow/python/eager/function.py in __call__(self, *args, **kwargs) 2939 with self._lock: 2940 (graph_function, -> 2941 filtered_flat_args) = self._maybe_define_function(args, kwargs) 2942 return graph_function._call_flat( 2943 filtered_flat_args, captured_inputs=graph_function.captured_inputs) # pylint: disable=protected-access ~/envs/project/lib/python3.8/site-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs) 3359 3360 self._function_cache.missed.add(call_context_key) -> 3361 graph_function = self._create_graph_function(args, kwargs) 3362 self._function_cache.primary[cache_key] = graph_function 3363 ~/envs/project/lib/python3.8/site-packages/tensorflow/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes) 3194 arg_names = base_arg_names + missing_arg_names 3195 graph_function = ConcreteFunction( -> 3196 func_graph_module.func_graph_from_py_func( 3197 self._name, 3198 self._python_function, ~/envs/project/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes) 988 _, original_func = tf_decorator.unwrap(python_func) 989 –> 990 func_outputs = python_func(*func_args, **func_kwargs) 991 992 # invariant: `func_outputs` contains only Tensors, CompositeTensors, ~/envs/project/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in wrapped_fn(*args, **kwds) 632 xla_context.Exit() 633 else: –> 634 out = weak_wrapped_fn().__wrapped__(*args, **kwds) 635 return out 636 ~/envs/project/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs) 975 except Exception as e: # pylint:disable=broad-except 976 if hasattr(e, “ag_error_metadata”): –> 977 raise e.ag_error_metadata.to_exception(e) 978 else: 979 raise ValueError: in user code: /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:805 train_function * return step_function(self, iterator) /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:795 step_function ** outputs = model.distribute_strategy.run(run_step, args=(data,)) /envs/project/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:1259 run return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica return self._call_for_each_replica(fn, args, kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica return fn(*args, **kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:788 run_step ** outputs = model.train_step(data) /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:754 train_step y_pred = self(x, training=True) /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1012 __call__ outputs = call_fn(inputs, *args, **kwargs) <ipython-input-16-f5ffc11fb617>:83 call ** x = keras.layers.Conv2D(64, 7, strides=2, padding=”same”)(inputs) /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1008 __call__ self._maybe_build(inputs) /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:2710 _maybe_build self.build(input_shapes) # pylint:disable=not-callable /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/layers/convolutional.py:198 build self.kernel = self.add_weight( /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:623 add_weight variable = self._add_variable_with_custom_getter( /envs/project/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py:805 _add_variable_with_custom_getter new_variable = getter( /envs/project/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer_utils.py:130 make_variable return tf_variables.VariableV1( /envs/project/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:260 __call__ return cls._variable_v1_call(*args, **kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:206 _variable_v1_call return previous_getter( /envs/project/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:67 getter return captured_getter(captured_previous, **kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:3332 creator return next_creator(**kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:67 getter return captured_getter(captured_previous, **kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:3332 creator return next_creator(**kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:67 getter return captured_getter(captured_previous, **kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:3332 creator return next_creator(**kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/ops/variables.py:67 getter return captured_getter(captured_previous, **kwargs) /envs/project/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py:730 invalid_creator_scope raise ValueError( ValueError: tf.function-decorated function tried to create variables on non-first call.

You can find my code in the link https://gofile.io/d/mTlna9 , what can i do to debug my code ?

Thank you for your advice

submitted by /u/Tensor_Beginner
[visit reddit] [comments]

Categories
Misc

Is the combination of high batch size and low epoch the same as that of low batch size and low epoch?

Sorry for the mistake in Question,

Is the combination of high batch size and low epoch the same as that of low batch size and high epoch?

Hey! I was just wondering …

If I try to generate High-resolution(128,128,3) images from Low resolution(32,32,3) images using GAN on a dataset of 1000 Images by following two methods :

Result_A: I run 100,000 epoch and batch_size =1 then my model will train on a total of 100,000 images. And this one image per epoch is selected randomly.

Result_B: I run 100 epochs on batch_size = 1000, then also my model trains on a total of 100,000 images.

Would Result_A be similar to Result_B? If not, why?

The differentiating factor is that in Result_B my model goes through all images, but it might not go through all images. Will this create a significant difference?

submitted by /u/shiami9
[visit reddit] [comments]

Categories
Misc

Book recommendations for tensorflowjs ?

Hey, I am interested in specifically learning tensorflow for JavaScript. I have learned the basics already and made some simple things like a model that predicts where crypto prices are going, but I keep running into walls trying to make things more complex.

I understand that all tensorflow works generally the same, but it would be cool if the book was JS focused (not a requirement). I would also appreciate a book that didn’t just throw a ton of formulas at you and instead took time to explain them. I have only taken up to calculus in college math so far. Thanks.

submitted by /u/grandcaravan2005
[visit reddit] [comments]

Categories
Misc

Has anyone had any success using Fiverr to do a tensorflow model for image recognition?

submitted by /u/NickLRealtor
[visit reddit] [comments]

Categories
Misc

Is there any way to install TF in a Docker container on an M1 Mac?

I’m trying to install Tensorflow 2.4.1 in a Docker container running Ubuntu 20.04 on my M1 MacBook Pro. I keep getting an error that says qemu: uncaught target signal 6 (Aborted) – core dumped

I’ve seen that this is common issue. I can get it to install and run fine on my base machine, it’s just when installing in the container that I have an issue.

Is there any way to install this properly? Thanks in advance!

submitted by /u/musicman0326
[visit reddit] [comments]

Categories
Misc

I have a trained handwritten character recognition model, is there an OCR I can feed it to?

Sorry if my question is misleading. I have built and trained a model which can determine what character is the input image (the image is a handwritten letter). I’d like to do not only 1 character, but let’s say a word or a text. Do I have to write my own code which segments the input image of a text/word into characters? If so where should I begin? Or is there a working segmenting model which I could just feed my trained model into then it would do the work?

Oh and the trained model consists of old latin handwritten characters.

I’m really new to this topic so any help would be appreciated! Thank you!

submitted by /u/punkw_
[visit reddit] [comments]

Categories
Misc

Set TensorFlow2 tensor to zero based on condition

I have a tensor in TensorFlow 2.5 where the goal is to set the smallest sum of magnitude based on p% of ‘slices’ to zeros. The sample code to achieve this is as follows:

# create example tensor- input_shape = (1, 4, 4, 6) y = tf.random.normal(input_shape) 

The goal is to find and remove the smallest (say) p = 20% of the values from the last index ‘6’ based on the sum of their magnitudes. floor(20% of 6) = 1, i.e., after removing 20% of smallest magnitude summation of values, 5 of the 4×4 ‘slices’ should have non-zero values while the 6th slice should be equal to zero.

 # Sum magnitude values- filter_sum = tf.math.reduce_sum(input_tensor = tf.math.abs(y), axis = [1, 2], keepdims = False) filter_sum.shape # TensorShape([1, 6]) indices = tf.argsort(filter_sum) indices.shape # TensorShape([1, 6]) indices.numpy() # array([[0, 1, 4, 2, 5, 3]]) # 20% of 6 values = 1 math.floor(0.2 * 6) # 1 

In this example, the smallest 4×4 ‘slice’ in ‘y’ is the first slice as computed by ‘indices’. How do I proceed?

Thanks

submitted by /u/grid_world
[visit reddit] [comments]

Categories
Misc

Cannot read property ‘children’ of undefined with using Tensorflow Object Detection API model in tfjs

System information – Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes – OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 – Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A – TensorFlow.js installed from (npm or script link): npm install @tensorflow/tfjs – TensorFlow.js version (use command below): 3.6.0 – Browser version: Chrome 90 on Windows 10 – Tensorflow.js Converter Version: 3.6.0

Hyperlinks are capitalized to prevent confusion(because the color settings(and blue filter) on my monitor make it hard to see the difference between them)

Describe the current behavior I used transfer learning using a pretrained model from the Tensorflow Object Detection API, which i converted to tensorflow-js using the tensorflow-converter API in python. View the ipynb notebook HERE. I then followed @hugozanini’s REPO which had a template for using your tensorflow object detection models in javascript; I copied the index.json file and put it into a sandbox, replacing his model.json file with mine. The repo which contains it can be found here

Describe the expected behavior I was expecting the model to work and the program to run normally, like it did in this DEMO. Instead, I got

index.js:1437 TypeError: Cannot read property ‘children’ of undefined at operation_mapper.js:409 at Array.forEach (<anonymous>) at operation_mapper.js:403 at Array.forEach (<anonymous>) at OperationMapper.mapFunction (operation_mapper.js:401) at operation_mapper.js:163 at Array.reduce (<anonymous>) at OperationMapper.transformGraph (operation_mapper.js:162) at GraphModel.loadSync (graph_model.js:159) at GraphModel._callee$ (graph_model.js:119) at tryCatch (runtime.js:62) at Generator.invoke [as _invoke] (runtime.js:288) at Generator.prototype.<computed> [as next] (runtime.js:114) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25)

Standalone code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem. If possible, please share a link to Colab/CodePen/any notebook.

HERE is the colab notebook I used to train my model HERE is the sandbox where I tried to use the tensorflow.js model

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

Error Message:

index.js:1437 TypeError: Cannot read property ‘children’ of undefined at operation_mapper.js:409 at Array.forEach (<anonymous>) at operation_mapper.js:403 at Array.forEach (<anonymous>) at OperationMapper.mapFunction (operation_mapper.js:401) at operation_mapper.js:163 at Array.reduce (<anonymous>) at OperationMapper.transformGraph (operation_mapper.js:162) at GraphModel.loadSync (graph_model.js:159) at GraphModel._callee$ (graph_model.js:119) at tryCatch (runtime.js:62) at Generator.invoke [as _invoke] (runtime.js:288) at Generator.prototype.<computed> [as next] (runtime.js:114) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25)

submitted by /u/dewball345
[visit reddit] [comments]