AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'

Viewed 17010

I want to resize images from 28*28 to 32*32,used tf.image.resize_images(x_train, (32, 32)).It returns AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'.The version of tersorflow is 2.0.0. How can I fix it?

6 Answers
  1. The problem The tf.image.resize_image function has not been support longer and when you execute the code like below:
import tensorflow as tf

img_final = tf.image.resize_images(img_tensor, [192, 192])

You get the following exception:

AttributeError: module 'tensorflow._api.v2.image' has no attribute 'resize_images'

  1. The solution The function has been renamed into resize. You should change your code like it was done below:
import tensorflow as tf

import tensorflow as tf

img_final = tf.image.resize(img_tensor, [192, 192])

For more info please check here: https://www.google.com/amp/s/better-coding.com/solved-tensorflow-attributeerror-module-tensorflow-_api-v2-image-has-no-attribute-resize_images/amp/

The function has been renamed to resize. You should change your code like it was done below. It worked for me.

import tensorflow as tf

img_final = tf.image.resize(img_tensor, [192, 192])

The function has been renamed into resize. The code can be changed as follows;

import tensorflow as tf

img_A=tf.image.resize(................)

Related