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

Viewed 320

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

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
Related