Google colab上Tensorflow 1的问题

按学习教程,复制了一段代码在google colab上运行。代码是没问题的,但是我运行出错。

%tensorflow_version 1.x
import tensorflow as tf
!pip install googledrivedownloader

ValueError: Tensorflow 1 is unsupported in Colab.

Your notebook should be updated to use Tensorflow 2.
See the guide at https://www.tensorflow.org/guide/migrate#migrate-from-tensorflow-1x-to-tensorflow-2.

是colab现在不支持Tensorflow 1了吗?还是我电脑硬件问题?

请各位帮帮忙,谢谢!

看这意思是只支持tensorflow2了,可以import的时候换成import tensorflow.compat.v1 as tf看看

你可以参考下这篇文章:基于Google Colab的tensorflow 1.8+深度学习教程

替换成以下代码:
%tensorflow_version 2.x

%tensorflow_version 1.x

import tensorflow as tf

解决!