试图在jyputer笔记本中运行styleGAN,它说"tensorflow' has no attribute 'Dimension"



在这里输入图片描述!python encode_images.py——optimizer=lbfgs——face_mask=True——iterations=6——use_lpips_loss=0——use_discriminator_loss=0——output_video=True aligned_images/generated_images/latent_representations/

print("n************潜在代码优化完成!***************& ")

2021-08-24 13:33:11.033451: I tensorflow/stream_executor/platform/default/dso_loader. exe[cc:48]成功打开动态库cudart64_101.dll

Traceback(最近一次调用):文件"encode_images.py",第12行进口dnnlib。就像这样文件"C:UsersbkvijOffice Rapid InnovationStyleGAN Face Morphing - Arxiv Insights StyleGAN -encoderdnnlibtflib_init_.py",第8行,in

。进口autosummary文件"C:UsersbkvijOffice Rapid InnovationStyleGAN Face Morphing - Arxiv Insights StyleGAN -encoderdnnlibtflibautosummary.py",第31行,in

。进口tfutil文件"C:UsersbkvijOffice Rapid InnovationStyleGAN Face Morphing - Arxiv Insights StyleGAN -encoderdnnlibtflib tfutile .py",第34行,in

def shape_to_list(shape: Iterable[tf.Dimension]) ->列表[联盟[int,没有]]:AttributeError:模块"tensorflow"没有属性"Dimension">

这是因为。尺寸已弃用。

转到stylegan/dnnlib/tflib/tfutil.py,将第34行中的tf.Dimension改为tf.compat.v1.Dimension

我认为你正在使用TensorFlow v2,使用google colape,它将为你解决问题,否则,你将需要使用Python 3.6 TensorFlow 1.10 cuDNN 7.3.1创建虚拟环境它会解决问题

要展开Faezeh的回答,您必须对tfutils.py

进行以下编辑从tf.Dimension(第34行)tf.variable_scope(第74行)tf.Session(第128行)

tf.compat.v1.Dimensiontf.compat.v1.variable_scopetf.compat.v1.Session

或者,你可以下载tensorflow 1。为自己省去麻烦

你可以使用它在终端' PIP安装tensorflow-addons==0.14.0

相关内容

最新更新