# \#pytorch

**URL:** https://discuss.ai.google.dev/tag/pytorch/308.md

[Latest](https://discuss.ai.google.dev/latest.md) · [Categories](https://discuss.ai.google.dev/categories.md) · [Tags](https://discuss.ai.google.dev/tags.md)

---

## [Why Naive PyTorch Hooks Slow Your Model](https://discuss.ai.google.dev/t/why-naive-pytorch-hooks-slow-your-model/199321)

<div class="topic-metadata">

**Author:** [@Abdelhak\_Azzouz](https://discuss.ai.google.dev/u/Abdelhak_Azzouz)\
**Replies:** 1\
**Last updated:** [November 11, 2026, 1:44pm UTC](https://discuss.ai.google.dev/t/why-naive-pytorch-hooks-slow-your-model/199321 "2026-11-11T13:44:09Z")

</div>

One line, .cpu(), inside a forward hook can stall your whole GPU. To record activations you attach a hook to a layer. The obvious version copies the tensor to the CPU right away: python def hook(module, inp, out): da…

---

## [What Is Inside an LLM? Meet GlassBox](https://discuss.ai.google.dev/t/what-is-inside-an-llm-meet-glassbox/199320)

<div class="topic-metadata">

**Author:** [@Abdelhak\_Azzouz](https://discuss.ai.google.dev/u/Abdelhak_Azzouz)\
**Replies:** 0\
**Last updated:** [November 10, 2026, 1:09am UTC](https://discuss.ai.google.dev/t/what-is-inside-an-llm-meet-glassbox/199320 "2026-11-10T01:09:01Z")

</div>

When an AI model refuses a request or gets something wrong, its logs only show the text going in and out. They don’t show why it answered that way. Most LLM monitoring tools (LangSmith, OpenTelemetry, Weights & Biases)…

---

## [Gemma 4 27B-A4B-it (MoE) on Vertex AI: vLLM Dependency Triangles, LoRA, and Vision Blockers](https://discuss.ai.google.dev/t/gemma-4-27b-a4b-it-moe-on-vertex-ai-vllm-dependency-triangles-lora-and-vision-blockers/141868)

<div class="topic-metadata">

**Author:** [@Manzela](https://discuss.ai.google.dev/u/Manzela)\
**Replies:** 1\
**Last updated:** [April 27, 2026, 12:54pm UTC](https://discuss.ai.google.dev/t/gemma-4-27b-a4b-it-moe-on-vertex-ai-vllm-dependency-triangles-lora-and-vision-blockers/141868 "2026-04-27T12:54:11Z")

</div>

Hello everyone, Over the past few weeks, I’ve been working on deploying Google’s Gemma 4 27B-A4B-it (Mixture-of-Experts) model on Vertex AI using vLLM. After extensive testing (30+ container/model versions), I successfu…

---

## [How to extract features from a pretrained model without calling \`predict()\` on any input?](https://discuss.ai.google.dev/t/how-to-extract-features-from-a-pretrained-model-without-calling-predict-on-any-input/110926)

<div class="topic-metadata">

**Author:** [@khteh](https://discuss.ai.google.dev/u/khteh)\
**Replies:** 1\
**Last updated:** [February 18, 2026, 7:25am UTC](https://discuss.ai.google.dev/t/how-to-extract-features-from-a-pretrained-model-without-calling-predict-on-any-input/110926 "2026-02-18T07:25:57Z")

</div>

I am migrating a legacy app from Torch which uses VGG19 pretrained model. The following code: vgg\_features = VGG19(weights='imagenet', include\_top=False) self.f1 = Sequential(\*\[vgg\_features\[x\] for x in range(2)\]) hits …

---

## [InstanceNormalization](https://discuss.ai.google.dev/t/instancenormalization/108210)

<div class="topic-metadata">

**Author:** [@khteh](https://discuss.ai.google.dev/u/khteh)\
**Replies:** 1\
**Last updated:** [November 5, 2025, 4:55pm UTC](https://discuss.ai.google.dev/t/instancenormalization/108210 "2025-11-05T16:55:27Z")

</div>

What’s the equivalent of PyTorch InstanceNorm2d(channels)? I use BatchNormalization(axis=1) and using it with input of shape (n\_test, image\_channels, image\_size, image\_size) doesn’t seem to transform anything at all.

---

## [Pytorch dataloader transforms and keras 3.0 model training](https://discuss.ai.google.dev/t/pytorch-dataloader-transforms-and-keras-3-0-model-training/71531)

<div class="topic-metadata">

**Author:** [@Atia](https://discuss.ai.google.dev/u/Atia)\
**Replies:** 2\
**Last updated:** [September 25, 2025, 8:01pm UTC](https://discuss.ai.google.dev/t/pytorch-dataloader-transforms-and-keras-3-0-model-training/71531 "2025-09-25T20:01:37Z")

</div>

In most pytorch training, one of the augmentations applied to both the train and validation set is Normalization especially when doing transfer learning like so for Imagenet dataset; transforms.Normalization( …

---

## [Can I install TensorFlow2.18 or 2.19\[and-cuda\] on an NVIDIA 5090 on Ubuntu 22.04 or later?](https://discuss.ai.google.dev/t/can-i-install-tensorflow2-18-or-2-19-and-cuda-on-an-nvidia-5090-on-ubuntu-22-04-or-later/76174)

<div class="topic-metadata">

**Author:** [@Sangmin\_Suh](https://discuss.ai.google.dev/u/Sangmin_Suh)\
**Replies:** 1\
**Last updated:** [September 4, 2025, 10:19am UTC](https://discuss.ai.google.dev/t/can-i-install-tensorflow2-18-or-2-19-and-cuda-on-an-nvidia-5090-on-ubuntu-22-04-or-later/76174 "2025-09-04T10:19:52Z")

</div>

I’ve tried a few times, but without success. If not yet, when will you be able to support 50 series GPUs? I’d like to know a rough timeline for budgeting purposes. I recently tried to install tensorflow on a 5070ti and …

---

## [Copy weights from PyTorch GRU layer to TensorFlow](https://discuss.ai.google.dev/t/copy-weights-from-pytorch-gru-layer-to-tensorflow/91650)

<div class="topic-metadata">

**Author:** [@Nada-Nada](https://discuss.ai.google.dev/u/Nada-Nada)\
**Replies:** 1\
**Last updated:** [July 8, 2025, 11:08am UTC](https://discuss.ai.google.dev/t/copy-weights-from-pytorch-gru-layer-to-tensorflow/91650 "2025-07-08T11:08:50Z")

</div>

Hello, I am trying to copy weights from a PyTorch GRU layer to TensorFlow. My layers def are: layers.GRU(units=100, activation=None, dropout=0.0, reset\_after=True) nn.GRU(input\_size=400, hidden\_size=100, bidirectional…

---

## [Fine-tuning a pre-trained model while replacing one of the pre-trained layers with a new PyTorchlayer](https://discuss.ai.google.dev/t/fine-tuning-a-pre-trained-model-while-replacing-one-of-the-pre-trained-layers-with-a-new-pytorchlayer/39242)

<div class="topic-metadata">

**Author:** [@Conor\_Warren](https://discuss.ai.google.dev/u/Conor_Warren)\
**Replies:** 1\
**Last updated:** [March 16, 2025, 1:09pm UTC](https://discuss.ai.google.dev/t/fine-tuning-a-pre-trained-model-while-replacing-one-of-the-pre-trained-layers-with-a-new-pytorchlayer/39242 "2025-03-16T13:09:04Z")

</div>

Hi everyone! I want to fine-tune a pre-trained BERT model off of the official BERT repository. I want to replace one of the pre-trained dense layers with a custom PyTorch layer. I’ve been trying to implement this, but …

---

## [Single channel speech separation using Neural Networks](https://discuss.ai.google.dev/t/single-channel-speech-separation-using-neural-networks/59847)

<div class="topic-metadata">

**Author:** [@Desouter\_Elias](https://discuss.ai.google.dev/u/Desouter_Elias)\
**Replies:** 0\
**Last updated:** [January 9, 2025, 5:43pm UTC](https://discuss.ai.google.dev/t/single-channel-speech-separation-using-neural-networks/59847 "2025-01-09T17:43:05Z")

</div>

Hello I’m trying to train a model that separates 2 speakers from a noisy, reverberated mixed audio file. I first try to train the model with only 1 mixed file and test the model with the same file to see if the model e…

---

## [Training With Probabilities](https://discuss.ai.google.dev/t/training-with-probabilities/51744)

<div class="topic-metadata">

**Author:** [@pbousquet](https://discuss.ai.google.dev/u/pbousquet)\
**Replies:** 0\
**Last updated:** [November 27, 2024, 10:00pm UTC](https://discuss.ai.google.dev/t/training-with-probabilities/51744 "2024-11-27T22:00:39Z")

</div>

One of my output layers corresponds to a probability. Some of the loss components depend on realizations conditional on this probability. I have continued to pair my model further and further down but still there is a la…

---

## [Convert Any PyTorch ML Model to TensorFlow, JAX, or NumPy with Ivy! 🚀 + New Kornia Integration](https://discuss.ai.google.dev/t/convert-any-pytorch-ml-model-to-tensorflow-jax-or-numpy-with-ivy-new-kornia-integration/48163)

<div class="topic-metadata">

**Author:** [@Yusha\_Arif](https://discuss.ai.google.dev/u/Yusha_Arif)\
**Replies:** 0\
**Last updated:** [November 7, 2024, 4:35pm UTC](https://discuss.ai.google.dev/t/convert-any-pytorch-ml-model-to-tensorflow-jax-or-numpy-with-ivy-new-kornia-integration/48163 "2024-11-07T16:35:44Z")

</div>

Hey everyone! Just wanted to share something exciting for those of you working across multiple ML frameworks. Ivy is a Python package that allows you to seamlessly convert ML models and code between frameworks like PyTo…

---

## [How to analyze model performance in TF?](https://discuss.ai.google.dev/t/how-to-analyze-model-performance-in-tf/36580)

<div class="topic-metadata">

**Author:** [@shaoyu\_young](https://discuss.ai.google.dev/u/shaoyu_young)\
**Replies:** 2\
**Last updated:** [August 20, 2024, 9:48am UTC](https://discuss.ai.google.dev/t/how-to-analyze-model-performance-in-tf/36580 "2024-08-20T09:48:08Z")

</div>

PyTorch provides an API torch.profiler to analyze the model performance (e.g., execution time and memory allocation). Is there a similar API in TesnforFlow?

---

## [How to define BatchNorm3d in tensorflow](https://discuss.ai.google.dev/t/how-to-define-batchnorm3d-in-tensorflow/35317)

<div class="topic-metadata">

**Author:** [@Nada-Nada](https://discuss.ai.google.dev/u/Nada-Nada)\
**Replies:** 7\
**Last updated:** [August 13, 2024, 11:31am UTC](https://discuss.ai.google.dev/t/how-to-define-batchnorm3d-in-tensorflow/35317 "2024-08-13T11:31:06Z")

</div>

PyTorch has three types of BatchNorm layers: BatchNorm1d, BatchNorm2d and BatchNorm3d. TensorFlow has only one BatchNormalization layer. Are these layers equivalent? I mean, can the three PyTorch layers be defined using…

---

## ["TypeError: 'TensorSpec' object is not iterable" when I run model.predict() in keras 3.0](https://discuss.ai.google.dev/t/typeerror-tensorspec-object-is-not-iterable-when-i-run-model-predict-in-keras-3-0/35421)

<div class="topic-metadata">

**Author:** [@Atia](https://discuss.ai.google.dev/u/Atia)\
**Replies:** 2\
**Last updated:** [August 9, 2024, 12:07pm UTC](https://discuss.ai.google.dev/t/typeerror-tensorspec-object-is-not-iterable-when-i-run-model-predict-in-keras-3-0/35421 "2024-08-09T12:07:05Z")

</div>

I have successfully trained a model using pytorch dataloaders and keras 3.0 api. However I run into this error TypeError: 'TensorSpec' object is not iterable when I run model.predict(data) where data is a pytorch dataloa…

---

## [Conversio yolo pytorch model to tflite for deploying it on mobile](https://discuss.ai.google.dev/t/conversio-yolo-pytorch-model-to-tflite-for-deploying-it-on-mobile/30832)

<div class="topic-metadata">

**Author:** [@INSAAF\_SULAIMAANSA](https://discuss.ai.google.dev/u/INSAAF_SULAIMAANSA)\
**Replies:** 1\
**Last updated:** [June 24, 2024, 11:28am UTC](https://discuss.ai.google.dev/t/conversio-yolo-pytorch-model-to-tflite-for-deploying-it-on-mobile/30832 "2024-06-24T11:28:55Z")

</div>

sys.exit(entrypoint()) File “/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/init.py”, line 448, in entrypoint getattr(model, mode)(\*\*overrides) # default args from model File “/usr/local/lib/python3.10/dist-…

---

## [I wrote a machine learning library based on TensorFlow](https://discuss.ai.google.dev/t/i-wrote-a-machine-learning-library-based-on-tensorflow/30565)

<div class="topic-metadata">

**Author:** [@NoteDancing](https://discuss.ai.google.dev/u/NoteDancing)\
**Replies:** 0\
**Last updated:** [June 4, 2024, 11:45am UTC](https://discuss.ai.google.dev/t/i-wrote-a-machine-learning-library-based-on-tensorflow/30565 "2024-06-04T11:45:48Z")

</div>

Note is a system(library) for deep learning and reinforcement learning. Note makes the building and training of neural networks easy and flexible. Note.nn.layer package contains many layer modules, you can use them to bu…

---

## [Bridging the Gap: TensorFlow LSTMCell & Optimizer Conversion to PyTorch pen\_spark](https://discuss.ai.google.dev/t/bridging-the-gap-tensorflow-lstmcell-optimizer-conversion-to-pytorch-pen-spark/24069)

<div class="topic-metadata">

**Author:** [@HrridoyV2](https://discuss.ai.google.dev/u/HrridoyV2)\
**Replies:** 0\
**Last updated:** [June 3, 2024, 2:18am UTC](https://discuss.ai.google.dev/t/bridging-the-gap-tensorflow-lstmcell-optimizer-conversion-to-pytorch-pen-spark/24069 "2024-06-03T02:18:54Z")

</div>

I’m embarking on an ambitious project – translating a TensorFlow model into the world of PyTorch. I’ve successfully navigated most of the conversion, but I’ve hit a roadblock when it comes to replicating the behavior of …

---

## [Tensorflow with pytorch's most essential feature](https://discuss.ai.google.dev/t/tensorflow-with-pytorchs-most-essential-feature/22268)

<div class="topic-metadata">

**Author:** [@Pratyush\_Singh](https://discuss.ai.google.dev/u/Pratyush_Singh)\
**Replies:** 1\
**Last updated:** [May 15, 2024, 9:48am UTC](https://discuss.ai.google.dev/t/tensorflow-with-pytorchs-most-essential-feature/22268 "2024-05-15T09:48:32Z")

</div>

Will Tensorflow introduce pytorch feature of changing parameters while training??

---

## [KL Divergence in PixelCNN](https://discuss.ai.google.dev/t/kl-divergence-in-pixelcnn/24706)

<div class="topic-metadata">

**Author:** [@Vaibhav\_Chahar](https://discuss.ai.google.dev/u/Vaibhav_Chahar)\
**Replies:** 0\
**Last updated:** [April 15, 2024, 3:11am UTC](https://discuss.ai.google.dev/t/kl-divergence-in-pixelcnn/24706 "2024-04-15T03:11:42Z")

</div>

Hi, I tried to use Kl Divergence Loss function in Gated PixelCNN but till now no success. in KL divergence It is required to have y\_true and y\_pred. I am sampling my input from the Neural network itself. The code for sam…

---

## [Converting model TF model to PyTorch](https://discuss.ai.google.dev/t/converting-model-tf-model-to-pytorch/25229)

<div class="topic-metadata">

**Author:** [@blessedg](https://discuss.ai.google.dev/u/blessedg)\
**Replies:** 0\
**Last updated:** [March 28, 2024, 7:16am UTC](https://discuss.ai.google.dev/t/converting-model-tf-model-to-pytorch/25229 "2024-03-28T07:16:17Z")

</div>

I have this tensorflow code that uses ragged tensor data import tensorflow as tf import keras.backend as K class Baseline\_cbr\_mb(tf.keras.Model): mean\_std\_scores\_fields = { "flow\_traffic", "flow\_pac…

---

## [Memory Resident Vision Model](https://discuss.ai.google.dev/t/memory-resident-vision-model/30182)

<div class="topic-metadata">

**Author:** [@bruce\_baur](https://discuss.ai.google.dev/u/bruce_baur)\
**Replies:** 0\
**Last updated:** [March 7, 2024, 2:39am UTC](https://discuss.ai.google.dev/t/memory-resident-vision-model/30182 "2024-03-07T02:39:43Z")

</div>

I have a pytorch model working using computer vision and each time I need to run detect.py. This takes a few seconds to load and produce the output predictions. I was seeking a way to have a CV model always running and…

---

## [Gradient Difference Loss of two images in TensorFlow](https://discuss.ai.google.dev/t/gradient-difference-loss-of-two-images-in-tensorflow/28738)

<div class="topic-metadata">

**Author:** [@marcocintra](https://discuss.ai.google.dev/u/marcocintra)\
**Replies:** 1\
**Last updated:** [March 6, 2024, 2:41pm UTC](https://discuss.ai.google.dev/t/gradient-difference-loss-of-two-images-in-tensorflow/28738 "2024-03-06T14:41:23Z")

</div>

Hi, how can I implement the Gradient Difference Loss of two images in TensorFlow (in sequential model), like that made using PyTorch (pytorch-GDL/custom\_loss\_functions.py at main · mmany/pytorch-GDL · GitHub)? Thanks!

---

## [Launching Google Gemma](https://discuss.ai.google.dev/t/launching-google-gemma/29224)

<div class="topic-metadata">

**Author:** [@pradeepkuppala](https://discuss.ai.google.dev/u/pradeepkuppala)\
**Replies:** 0\
**Last updated:** [February 28, 2024, 6:50pm UTC](https://discuss.ai.google.dev/t/launching-google-gemma/29224 "2024-02-28T18:50:23Z")

</div>

\[Model Launch\] Welcome Google’s Gemma! Recently, Google announced a new family of open large language models called Gemma. It was built from the same research and technology used to create Gemini. We worked hard behind t…

---

## [cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version](https://discuss.ai.google.dev/t/cudagetdevice-failed-status-cuda-driver-version-is-insufficient-for-cuda-runtime-version/31681)

<div class="topic-metadata">

**Author:** [@jpainam](https://discuss.ai.google.dev/u/jpainam)\
**Replies:** 1\
**Last updated:** [February 26, 2024, 6:27am UTC](https://discuss.ai.google.dev/t/cudagetdevice-failed-status-cuda-driver-version-is-insufficient-for-cuda-runtime-version/31681 "2024-02-26T06:27:22Z")

</div>

Hi, I’m able to load a specific version of cuda if I know which version tensorflow was compiled with during install. In pytorch, I could do torch.version.cuda, and if there is mismatch between the current loaded cuda a…

---

## [Model visualization for covariance between input variables](https://discuss.ai.google.dev/t/model-visualization-for-covariance-between-input-variables/25655)

<div class="topic-metadata">

**Author:** [@hawkiyc](https://discuss.ai.google.dev/u/hawkiyc)\
**Replies:** 0\
**Last updated:** [December 26, 2023, 3:37am UTC](https://discuss.ai.google.dev/t/model-visualization-for-covariance-between-input-variables/25655 "2023-12-26T03:37:49Z")

</div>

Hi, I have built a VAE model with pytorch for dealing with tabular oceanographical data. My question is, what shall I do to visualize model weight and clarify the covariance relationship between input variables, as show…

---

## [Calculate Flops in Tensorflow and Pytorch are not equal?](https://discuss.ai.google.dev/t/calculate-flops-in-tensorflow-and-pytorch-are-not-equal/23235)

<div class="topic-metadata">

**Author:** [@mrgreen3325](https://discuss.ai.google.dev/u/mrgreen3325)\
**Replies:** 14\
**Last updated:** [December 22, 2023, 3:48am UTC](https://discuss.ai.google.dev/t/calculate-flops-in-tensorflow-and-pytorch-are-not-equal/23235 "2023-12-22T03:48:15Z")

</div>

Given the same model, I found that the calculated flops in pytorch and tensorflow are different. I used the keras\_flops (keras-flops · PyPI) in tensorflow, and ptflops (ptflops · PyPI) in pytorch to calculate flops. It s…

---

## [Onnx-tf -\> com.microsoft::FusedMatMul operator not implemented](https://discuss.ai.google.dev/t/onnx-tf-com-microsoft-fusedmatmul-operator-not-implemented/32182)

<div class="topic-metadata">

**Author:** [@MG-EuS](https://discuss.ai.google.dev/u/MG-EuS)\
**Replies:** 1\
**Last updated:** [December 21, 2023, 9:22pm UTC](https://discuss.ai.google.dev/t/onnx-tf-com-microsoft-fusedmatmul-operator-not-implemented/32182 "2023-12-21T21:22:46Z")

</div>

Hello, I need to convert a model that is implemented in pytorch to tensorflow lite. I have exported the model to onnx using torch.onnx.export(). The resulting onnx model works very well with the onnx-runtime. But when I…

---

## [Cannot use GPU on tensorflow with CUDA Toolkit 12.3](https://discuss.ai.google.dev/t/cannot-use-gpu-on-tensorflow-with-cuda-toolkit-12-3/32562)

<div class="topic-metadata">

**Author:** [@tuanminh](https://discuss.ai.google.dev/u/tuanminh)\
**Replies:** 2\
**Last updated:** [December 4, 2023, 7:57am UTC](https://discuss.ai.google.dev/t/cannot-use-gpu-on-tensorflow-with-cuda-toolkit-12-3/32562 "2023-12-04T07:57:04Z")

</div>

Hello everyone. I am a newbie. I downloaded CUDA Toolkit version 12.3 and its corresponding CuDNN. I have used GPU successfully on pytorch but with tensorflow it doesn’t work. I tried running on colab and found that te…

---

## [No module named 'tensorflow.compat'](https://discuss.ai.google.dev/t/no-module-named-tensorflow-compat/32090)

<div class="topic-metadata">

**Author:** [@Kevin\_Kate](https://discuss.ai.google.dev/u/Kevin_Kate)\
**Replies:** 1\
**Last updated:** [July 26, 2023, 6:13am UTC](https://discuss.ai.google.dev/t/no-module-named-tensorflow-compat/32090 "2023-07-26T06:13:45Z")

</div>

import torch import torch.nn as nn from keras.preprocessing.sequence import pad\_sequences from keras.preprocessing.text import Tokenizer this is my code i get the following attached error. This code is executed in V…

[Next page](https://discuss.ai.google.dev/tag/pytorch/308.md?match_all_tags=true&page=1&tags%5B%5D=pytorch)
