Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'tensorflow.compat.v2.tpu.experimental' has no attribute 'HardwareFeature'

Running below code gave the error as AttributeError: module 'tensorflow.compat.v2.tpu.experimental' has no attribute 'HardwareFeature'

import os
import pprint
import tempfile

from typing import Dict, Text

import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_datasets as tfds

!pip install -q tensorflow-recommenders

import tensorflow_recommenders as tfrs

tensorflow version used was 2.9.1 and the code was run from Google Colab

like image 539
sakeesh Avatar asked Jun 01 '26 20:06

sakeesh


1 Answers

Did a trial and error changed the order of execution as below and it worked fine no errors this time

!pip install -q tensorflow-recommenders

import os
import pprint
import tempfile

from typing import Dict, Text

import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_datasets as tfds

import tensorflow_recommenders as tfrs
like image 166
sakeesh Avatar answered Jun 04 '26 11:06

sakeesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!