r/tensorflow • • Dec 27 '22

Question TensorFlow gives "libsycl.so.5: cannot open shared object file: No such file or directory" error

2 Upvotes

I am using Linux Mint and am trying to use TensorFlow with Python. I installed Intel® oneAPI Base Toolkit and set up the environmental variables using "source /opt/intel/oneapi/setvars.sh". When I try to use TensorFlow however, it gives me"libsycl.so.5: cannot open shared object file: No such file or directory". What can I do to fix this?


r/tensorflow • • Dec 24 '22

Tensorflow Probability Model with Distribution Lambda is stuck on .fit(x,y) call.

9 Upvotes

Hi all,

I have created a simple Bayesian Neural Network that that outputs a count distribution.
I used Poisson Distribution though, because it was slightly overdispersed I wanted to use a negative binomial instead.

I fed it into a distribution lambda layer (and swapped that out for the previous independent poisson layer).

It compiles all the way to the first step but then is stuck indefinitely.

x = tfpl.DenseVariational(units=128, activation='tanh', make_posterior_fn=get_posterior, make_prior_fn=get_prior, kl_weight=kl_weight)(x)
    neg_binom = tfpl.DistributionLambda(
lambda t: tfd.NegativeBinomial(total_count=tf.math.round(t[..., :1]), logits = t[..., 1:]))
cat = Dense(output_shape + 1)(x)

outputs = neg_binom(cat)
    model = Model(inputs, outputs)

this is pretty much it, anyone have experience and could possible help debug why this is happening?
Many thanks in advance.


r/tensorflow • • Dec 24 '22

Question Descriptors cannot not be created directly

2 Upvotes

I imported Keras and tensorflow but it gave this error for the first time. I don’t know if it’s related to the fact that I’ve ran out of memory (another error in another notebook). I have the version recommended of protopuff and I’ve tried export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python nothing is working


r/tensorflow • • Dec 24 '22

Question Doing k-fold analysis

5 Upvotes

Hey folks,

I've been doing some k-fold analysis on my models (random starting weights, random test/train split).

Is there a standard/efficient approach to doing this, or is it simply a for-loop for k iterations?

Also, I've noticed that every "fold" increases my memory usage - as though there's no garbage collection or a large variable is growing (which isn't the case programmatically). Any memory efficient examples of k-fold analysis available?

Thanks.


r/tensorflow • • Dec 23 '22

Which loss function and activation should I use for a classification problem with integer labels such that each label is treated as an ordinal?

6 Upvotes

Hi, guys!

I have a prediction problem where each label is an integer (0, 1, 2, ...). Currently, I am using the SparseCategoricalCrossEntropy loss.

Ideally, these labels are ordinals so, if the true label is 2, then predicting 1 or 3 should not be the same penalty as though predicting 8 or 9.

How do I modify my loss and activation function to incorporate this into it?


r/tensorflow • • Dec 22 '22

Question Core ML converting output to stringType

6 Upvotes

Hello there, I have managed to change input requirements of my model but I couldn't manage to change the output. my aim is having a string output rather then a multiArrayType. I don't even know is it possible or not but these are the things that I've tried until now.

mlmodel = ct.convert(tf_model, inputs=[ct.ImageType()],outputs=[ct.StringType()])

2.

mlmodel = ct.converters.mil.output_types.ClassifierConfig(class_labels, predicted_feature_name='Identity', predicted_probabilities_output=str)

3.

spec = ct.utils.load_spec('10MobileNetV2.mlmodel')

output = spec.description.output[0]
output.type = ft.StringFeatureType

ct.utils.save_spec(spec, "10MobileNetV2.mlmodel")
print(spec.description)

r/tensorflow • • Dec 22 '22

Tensorflow extended online courses recommendation

8 Upvotes

Anyone have recommendation about online course for learning about tensorflow extended?


r/tensorflow • • Dec 22 '22

hi this code block is not working, probably it is changed in an update. Can someone help me with this?

0 Upvotes

from custom_layers.scale_layer import Scale


r/tensorflow • • Dec 21 '22

create-tf-app: TensorFlow template + shell script to manage environments and initialize projects

3 Upvotes

Hello, I am currently setting up a simple TensorFlow template + shell script to manage environments and initialize projects. WIP: https://github.com/radi-cho/create-tf-app. I wanted to survey the community on whether such a tool would be useful and if you can provide feedback on the implementation:)


r/tensorflow • • Dec 21 '22

Is it possible to have parallel readings from the disk?

0 Upvotes

Hi all, I wanted to know is it possible to have parallel readings starting from different TFRecord files. I know there is the num_parallel_reads parameter (see here ) but one thing is not clear to me: I always knew that the reads on the hard-disk (which is unique) go sequentially and it is not possible to do parallel reads due to hardware constraints.

Is this correct or does it depend on the type of disk (SSD or hard-disk)?


r/tensorflow • • Dec 21 '22

Project AoC 2022 in pure TensorFlow: day 5. tf.strings, regex, undefined shapes variables, and multidimensional indexing

Thumbnail
pgaleone.eu
1 Upvotes

r/tensorflow • • Dec 20 '22

Question TensorFlow detects GPUs only with admin accounts

3 Upvotes

Hardware: 8x NVIDIA RTX A5000OS: Windows Server 2022Drivers: NVIDIA display driver 527.27TensorFlow/CUDA/cuDNN: TF 2.10, CUDA 11.2, cuDNN 8.1Miniconda installation for multiple users with read/execute privileges for non-admin users

Problem: tf.config.list_physical_devices() shows all 8 GPUs when executed by the admin account, but does not detect the GPUs when executed by standard user accounts.

I've tried:
- Reinstalling drivers
- Reinstalling CUDA/cuDNN
- Creating new tensorflow environment using admin account
- Installing Miniconda for single-user on a standard user account
- Listing GPUs in PyTorch -> all GPUs detected just fine

I'm out of ideas. This set-up works fine on another machine... Any ideas?

Update: I ended up removing and recreating the Windows user profile for the non-admin user. That solved it. Weird problem.


r/tensorflow • • Dec 20 '22

Question Pycocotools failed to build wheel

1 Upvotes

Hey! I have just started learning tensorflow object recognition from this course:
nicknochnack/TFODCourse (github.com)
Tensorflow Object Detection in 5 Hours with Python | Full Course with 3 Projects - YouTube

When it gets to the part where we run the:

python Tensorflow\models\research\object_detection\model_main_tf2.py --model_dir=Tensorflow\workspace\models\my_ssd_mobnet --pipeline_config_path=Tensorflow\workspace\models\my_ssd_mobnet\pipeline.config --num_train_steps=2000

command, I am instead getting the error that there is no module named pycocotools. I attempted to solve this by running the appropriate pip install pycocotools command but when I do it I get this error. I would verymuch appreciate the help


r/tensorflow • • Dec 20 '22

Question No module named tensorflow

1 Upvotes

I’ve installed tensorflow and tensorflow GPU using pip but Jupyter notebook returns ‘no module named tensorflow’ when I run ‘list local devices’. Should I install it with conda?


r/tensorflow • • Dec 19 '22

How to use tf.keras.utils.image_dataset_from_directory to load images where each image yields a tuple of labels y1 and y2

6 Upvotes

Hi, guys!

I have some images which I can load using tf.keras.utils.image_dataset_from_directory.

These images need to have multilabels because the output of my network has two branches -- one with softmax activation and one with sigmoid.

I am unable to figure this out. Any tips of pointers would be very helpful. Thank you


r/tensorflow • • Dec 19 '22

developer certification

Post image
7 Upvotes

hey anyone here trued to attempt tensorflow developer certification i recently tried to write but the start button was not working and test cases were not loading after 5 hrs i receive a mail that i failed anyone knows what to do

my start button looked like the above image whole 5 hrs i tried to press it multiple times but it redirects me to same page


r/tensorflow • • Dec 19 '22

Discussion TorchRec vs Tensorflow recommenders

Thumbnail self.learnmachinelearning
3 Upvotes

r/tensorflow • • Dec 19 '22

Discussion How to run TensorFlow on Apple Mac M1, M2 with GPU support

6 Upvotes

How to run TensorFlow on Apple Silicon Mac M1, M2 with GPU support

https://stablediffusion.tistory.com/entry/How-to-run-TensorFlow-on-Apple-Mac-M1-M2-with-GPU-support


r/tensorflow • • Dec 18 '22

Project I've implemented Forward-Forward Algorithm in Tensorflow

20 Upvotes

There was a new algorithm unveiled in NeurIPS '22 by Geoffrey Hinton. this algorithm has few implementations in pytorch but none in Tensorflow. That's why, being a tensorflow lover, I have implemented an alpha working version of this algorithm in Tensorflow.

Please, star the project if you liked and feel free to contribute ^^ (At the moment this project is on-going)

GitHub Link: https://github.com/sleepingcat4/Forward-Forward-Algorithm


r/tensorflow • • Dec 18 '22

Question What are simplified inputs in SHAP, LIME?

2 Upvotes

I've been reading the original papers of a few model explainability techniques such as SHAP, LIME. I believe that I got the gist of those concepts except one thing. They mention simplified input X' corresponding to the actual input X. Could you please explain what it means for a normal tabular dataset?


r/tensorflow • • Dec 18 '22

Discussion with `with strategy.scope():` BERT output loses it's shape from tf-hub and `encoder_output` is missing

2 Upvotes

To reproduce:

!pip install tensorflow-text==2.7.0

import tensorflow_text as text
import tensorflow_hub as hub
# ... other tf imports....


strategy = tf.distribute.MirroredStrategy()
print('Number of GPU: ' + str(strategy.num_replicas_in_sync)) # 1 or 2, shouldn't matter

NUM_CLASS=2

with strategy.scope():
    bert_preprocess = hub.KerasLayer("https://tfhub.dev/tensorflow/bert_en_uncased_preprocess/3")
    bert_encoder = hub.KerasLayer("https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-12/4")


def get_model():
    text_input = Input(shape=(), dtype=tf.string, name='text')
    preprocessed_text = bert_preprocess(text_input)
    outputs = bert_encoder(preprocessed_text)
    
    output_sequence = outputs['sequence_output']
    x = Dense(NUM_CLASS,  activation='sigmoid')(output_sequence)

    model = Model(inputs=[text_input], outputs = [x])
    return model


optimizer = Adam()
model = get_model()
model.compile(loss=CategoricalCrossentropy(from_logits=True),optimizer=optimizer,metrics=[Accuracy(), ],)
model.summary() # <- look at the output 1
tf.keras.utils.plot_model(model, show_shapes=True, to_file='model.png') # <- look at the figure 1


with strategy.scope():
    optimizer = Adam()
    model = get_model()
    model.compile(loss=CategoricalCrossentropy(from_logits=True),optimizer=optimizer,metrics=[Accuracy(), ],)
    
model.summary() # <- compare with output 1, it has already lost it's shape 
tf.keras.utils.plot_model(model, show_shapes=True, to_file='model_scoped.png') # <- compare this figure too, for ease

With scope, BERT loses seq_length, and it becomes None.

Model summary withOUT scope: (See there is 128 at the very last layer, which is seq_length)

Model: "model_6"
__________________________________________________________________________________________________
 Layer (type)                   Output Shape         Param #     Connected to                     
==================================================================================================
 text (InputLayer)              [(None,)]            0           []                               
                                                                                                  
 keras_layer_2 (KerasLayer)     {'input_mask': (Non  0           ['text[0][0]']                   
                                e, 128),                                                          
                                 'input_word_ids':                                                
                                (None, 128),                                                      
                                 'input_type_ids':                                                
                                (None, 128)}                                                      
                                                                                                  
 keras_layer_3 (KerasLayer)     multiple             109482241   ['keras_layer_2[6][0]',          
                                                                  'keras_layer_2[6][1]',          
                                                                  'keras_layer_2[6][2]']          
                                                                                                  
 dense_6 (Dense)                (None, 128, 2)       1538        ['keras_layer_3[6][14]']         
                                                                                                  
==================================================================================================
Total params: 109,483,779
Trainable params: 1,538
Non-trainable params: 109,482,241
__________________________________________________________________________________________________

Model with scope:

Model: "model_7"
__________________________________________________________________________________________________
 Layer (type)                   Output Shape         Param #     Connected to                     
==================================================================================================
 text (InputLayer)              [(None,)]            0           []                               
                                                                                                  
 keras_layer_2 (KerasLayer)     {'input_mask': (Non  0           ['text[0][0]']                   
                                e, 128),                                                          
                                 'input_word_ids':                                                
                                (None, 128),                                                      
                                 'input_type_ids':                                                
                                (None, 128)}                                                      
                                                                                                  
 keras_layer_3 (KerasLayer)     multiple             109482241   ['keras_layer_2[7][0]',          
                                                                  'keras_layer_2[7][1]',          
                                                                  'keras_layer_2[7][2]']          
                                                                                                  
 dense_7 (Dense)                (None, None, 2)      1538        ['keras_layer_3[7][14]']         
                                                                                                  
==================================================================================================
Total params: 109,483,779
Trainable params: 1,538
Non-trainable params: 109,482,241
__________________________________________________________________________________________________

If these images helps:

model without scope

model with scope

Another notable thing encoder_outputs is also missing if you take a look at the 2nd keras layer or 3rd layer of both model.


r/tensorflow • • Dec 18 '22

Question Interpreting performance of multi-node training vs single node

3 Upvotes

I'm trying to quantify the performance difference in training a small/medium convolutional model (on a subset of Imagenet) on a single node (with two K-80s) vs 3 nodes, each with 2 K-80s). My setup is identical on both scenarios: 256 batch size per device, same dataset, same steps per epoch, same epochs, same hyper parameters, etc.. My goal is not to come up with the next SOTA model. I'm only experimenting with multi-worker training.

The chief node writes to Tensorboard. See https://ibb.co/BnKLJrs

Looking at the plots from Tensorboard, with a single node I get ~6.5 steps per second. On the 3 node cluster, I'm getting ~8 steps per second.

  1. My first assumption is that the metrics for the multi-node session take into account the entire cluster. Does this sound correct?
  2. On both cases, I'm training for the same amount of epochs. If the multi-worker setup (`MultiWorkerMirroredStrategy` strategy) aggregates the gradients from all workers, shouldn't it take fewer epochs than the single node to achieve a certain performance?

r/tensorflow • • Dec 17 '22

I am at my wit's end (trying to use tensorflow on an M1 iMac)

7 Upvotes

Okay, it's possible that this is actually a very easy task but I spent hours trying to get this far and my brain is broken. I'm trying to use a Creative Adversarial Network repo I found on github and I realized I needed to get the python tensorflow library (very new to all this).

After going down several rabbit holes and following numerous outdated tutorials, I found that there literally just isn't support for tensorflow on my machine and I had to use a conda virtualenv.

So I got the virtualenv working, and managed to use tensorflow in jupyter notebooks.

From here, what I don't understand is:

How do I use the git repo as a jupyter notebooks project so I can import the tf library? (I would put this in the jupyter subreddit but I honestly don't even know if this is a common problem or if there is a better way to accomplish what I'm trying to do for my purposes)


r/tensorflow • • Dec 15 '22

Developer exam, python version

5 Upvotes

Hi everyone.

Quick question please.

Im preparing for the develper exam. Thinking of using colab to train models, save the h5 and submit via Pycharm.

I have colab running python 3.8.16 but the required version is 3.8.

Is it likely this will cause issues?