google-research / google-research

Google Research
https://research.google
Apache License 2.0
33.85k stars 7.84k forks source link

FVD example #638

Open Ian-Mint opened 3 years ago

Ian-Mint commented 3 years ago

Attempting to run frechet_video_distance/example.py I get the error:

NotImplementedError: Cannot convert a symbolic Tensor (covariance/Size_2:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

Ubuntu 20.04.2 LTS tensorflow version: 2.4.1

complete traceback:

  File "/home/ian/projects/frame-prediction-pytorch/fid/example.py", line 51, in <module>
    tf.app.run(main)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "/home/ian/projects/frame-prediction-pytorch/fid/example.py", line 40, in main
    result = fvd.calculate_fvd(
  File "/home/ian/projects/frame-prediction-pytorch/fid/frechet_video_distance.py", line 140, in calculate_fvd
    return tfgan.eval.frechet_classifier_distance_from_activations(real_activations, generated_activations)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow_gan/python/eval/classifier_metrics.py", line 792, in frechet_classifier_distance_from_activations
    return _frechet_classifier_distance_from_activations_helper(
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow_gan/python/eval/classifier_metrics.py", line 716, in _frechet_classifier_distance_from_activations_helper
    tfp.stats.covariance(activations1),)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow_probability/python/stats/sample_stats.py", line 438, in covariance
    tf.ones([sample_ndims], tf.int32)),
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py", line 3120, in ones
    output = _constant_if_small(one, shape, dtype, name)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py", line 2804, in _constant_if_small
    if np.prod(shape) < 1000:
  File "<__array_function__ internals>", line 5, in prod
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 3030, in prod
    return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out,
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 87, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
  File "/home/ian/miniconda3/envs/torch-tf/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 852, in __array__
    raise NotImplementedError(
NotImplementedError: Cannot convert a symbolic Tensor (covariance/Size_2:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

Conda environment:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                      1_llvm    conda-forge
_tflow_select             2.1.0                       gpu  
absl-py                   0.12.0             pyhd8ed1ab_0    conda-forge
aiohttp                   3.7.4            py38h497a2fe_0    conda-forge
astunparse                1.6.3              pyhd8ed1ab_0    conda-forge
async-timeout             3.0.1                   py_1000    conda-forge
attrs                     20.3.0             pyhd3deb0d_0    conda-forge
blas                      1.0                         mkl    conda-forge
blinker                   1.4                        py_1    conda-forge
brotlipy                  0.7.0           py38h497a2fe_1001    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.17.1               h7f98852_1    conda-forge
ca-certificates           2021.1.19            h06a4308_1  
cachetools                4.2.1              pyhd8ed1ab_0    conda-forge
cairo                     1.16.0            h7979940_1007    conda-forge
certifi                   2020.12.5        py38h578d9bd_1    conda-forge
cffi                      1.14.5           py38ha65f79e_0    conda-forge
chardet                   4.0.0            py38h578d9bd_1    conda-forge
click                     7.1.2              pyh9f0ad1d_0    conda-forge
cloudpickle               1.6.0                      py_0  
comet_ml                  3.5.0                      py38    comet_ml
configobj                 5.0.6                      py_0    conda-forge
cryptography              3.4.6            py38ha5dfef3_0    conda-forge
cudatoolkit               10.1.243             h036e899_8    conda-forge
cudnn                     7.6.5.32             hc0a50b0_1    conda-forge
cupti                     10.1.168                      0  
cycler                    0.10.0                     py_2    conda-forge
dbus                      1.13.6               hfdff14a_1    conda-forge
decorator                 4.4.2              pyhd3eb1b0_0  
dill                      0.3.3              pyhd3eb1b0_0  
dulwich                   0.20.20          py38h497a2fe_0    conda-forge
everett                   1.0.2                      py_1    comet_ml
expat                     2.2.10               h9c3ff4c_0    conda-forge
ffmpeg                    4.3.1                hca11adc_2    conda-forge
fontconfig                2.13.1            hba837de_1004    conda-forge
freetype                  2.10.4               h0708190_1    conda-forge
future                    0.18.2                   py38_1  
gast                      0.4.0              pyh9f0ad1d_0    conda-forge
gettext                   0.19.8.1          h0b5b191_1005    conda-forge
glib                      2.66.7               h9c3ff4c_1    conda-forge
glib-tools                2.66.7               h9c3ff4c_1    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
gnutls                    3.6.13               h85f3911_1    conda-forge
google-auth               1.24.0             pyhd3deb0d_0    conda-forge
google-auth-oauthlib      0.4.1                      py_2    conda-forge
google-pasta              0.2.0              pyh8c360ce_0    conda-forge
googleapis-common-protos  1.52.0           py38h06a4308_0  
graphite2                 1.3.13            h58526e2_1001    conda-forge
grpcio                    1.36.1           py38hdd6454d_0    conda-forge
gst-plugins-base          1.18.4               h29181c9_0    conda-forge
gstreamer                 1.18.4               h76c114f_0    conda-forge
h5py                      2.10.0          nompi_py38h7442b35_105    conda-forge
harfbuzz                  2.7.4                h5cf4720_0    conda-forge
hdf5                      1.10.6          nompi_h7c3c948_1111    conda-forge
icu                       68.1                 h58526e2_0    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
importlib-metadata        3.7.3            py38h578d9bd_0    conda-forge
jasper                    1.900.1           h07fcdf6_1006    conda-forge
jpeg                      9d                   h36c2ea0_0    conda-forge
jsonschema                3.2.0              pyhd8ed1ab_3    conda-forge
keras-preprocessing       1.1.2              pyhd8ed1ab_0    conda-forge
kiwisolver                1.3.1            py38h1fd1430_1    conda-forge
krb5                      1.17.2               h926e7f8_0    conda-forge
lame                      3.100             h7f98852_1001    conda-forge
lcms2                     2.12                 hddcbb42_0    conda-forge
ld_impl_linux-64          2.35.1               hea4e1c9_2    conda-forge
libblas                   3.9.0                     8_mkl    conda-forge
libcblas                  3.9.0                     8_mkl    conda-forge
libclang                  11.1.0          default_ha53f305_0    conda-forge
libcurl                   7.75.0               hc4aaa36_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               hcdb4288_3    conda-forge
libffi                    3.3                  h58526e2_2    conda-forge
libgcc-ng                 9.3.0               h2828fa1_18    conda-forge
libgfortran-ng            7.5.0               h14aa051_18    conda-forge
libgfortran4              7.5.0               h14aa051_18    conda-forge
libglib                   2.66.7               h3e27bee_1    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
liblapack                 3.9.0                     8_mkl    conda-forge
liblapacke                3.9.0                     8_mkl    conda-forge
libllvm11                 11.1.0               hf817b99_0    conda-forge
libnghttp2                1.43.0               h812cca2_0    conda-forge
libopencv                 4.5.1            py38h703c3c0_0    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libpq                     13.1                 hfd2b0eb_2    conda-forge
libprotobuf               3.15.6               h780b84a_0    conda-forge
libssh2                   1.9.0                ha56f1ee_6    conda-forge
libstdcxx-ng              9.3.0               h6de172a_18    conda-forge
libtiff                   4.2.0                hdc55705_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libuv                     1.41.0               h7f98852_0    conda-forge
libwebp-base              1.2.0                h7f98852_1    conda-forge
libxcb                    1.13              h7f98852_1003    conda-forge
libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
libxml2                   2.9.10               h72842e0_3    conda-forge
llvm-openmp               11.0.1               h4bd325d_0    conda-forge
lz4-c                     1.9.3                h9c3ff4c_0    conda-forge
markdown                  3.3.4              pyhd8ed1ab_0    conda-forge
matplotlib                3.3.4            py38h578d9bd_0    conda-forge
matplotlib-base           3.3.4            py38h0efea84_0    conda-forge
mkl                       2020.4             h726a3e6_304    conda-forge
mkl-service               2.3.0            py38h1e0a361_2    conda-forge
multidict                 5.1.0            py38h497a2fe_1    conda-forge
mysql-common              8.0.23               ha770c72_1    conda-forge
mysql-libs                8.0.23               h935591d_1    conda-forge
ncurses                   6.2                  h58526e2_4    conda-forge
nettle                    3.6                  he412f7d_0    conda-forge
ninja                     1.10.2               h4bd325d_0    conda-forge
nspr                      4.29                 h9c3ff4c_1    conda-forge
nss                       3.62                 hb5efdd6_0    conda-forge
numpy                     1.20.1           py38h18fd61f_0    conda-forge
nvidia-ml                 7.352.0                    py_0    conda-forge
oauthlib                  3.0.1                      py_0    conda-forge
olefile                   0.46               pyh9f0ad1d_1    conda-forge
opencv                    4.5.1            py38h578d9bd_0    conda-forge
openh264                  2.1.1                h780b84a_0    conda-forge
openssl                   1.1.1j               h27cfd23_0  
opt_einsum                3.3.0                      py_0    conda-forge
pcre                      8.44                 he1b5a44_0    conda-forge
pillow                    8.1.2            py38ha0e1e83_0    conda-forge
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
promise                   2.2.1                      py_0    powerai
protobuf                  3.15.6           py38h709712a_0    conda-forge
psutil                    5.8.0            py38h497a2fe_1    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
py-opencv                 4.5.1            py38h81c977d_0    conda-forge
pyasn1                    0.4.8                      py_0    conda-forge
pyasn1-modules            0.2.7                      py_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pyjwt                     2.0.1              pyhd8ed1ab_0    conda-forge
pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py38h578d9bd_7    conda-forge
pyqt-impl                 5.12.3           py38h7400c14_7    conda-forge
pyqt5-sip                 4.19.18          py38h709712a_7    conda-forge
pyqtchart                 5.12             py38h7400c14_7    conda-forge
pyqtwebengine             5.12.1           py38h7400c14_7    conda-forge
pyrsistent                0.17.3           py38h497a2fe_2    conda-forge
pysocks                   1.7.1            py38h578d9bd_3    conda-forge
python                    3.8.8           hffdb5ce_0_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python-flatbuffers        1.12               pyhd8ed1ab_0    conda-forge
python_abi                3.8                      1_cp38    conda-forge
pytorch                   1.7.0           py3.8_cuda10.1.243_cudnn7.6.3_0    pytorch
qt                        5.12.9               hda022c4_4    conda-forge
readline                  8.0                  he28a2e2_2    conda-forge
requests                  2.25.1             pyhd3deb0d_0    conda-forge
requests-oauthlib         1.3.0              pyh9f0ad1d_0    conda-forge
requests-toolbelt         0.9.1                      py_0    conda-forge
rsa                       4.7.2              pyh44b312d_0    conda-forge
scipy                     1.6.1            py38h91f5cce_0  
setuptools                49.6.0           py38h578d9bd_3    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.34.0               h74cdb3f_0    conda-forge
tensorboard               2.4.1              pyhd8ed1ab_0    conda-forge
tensorboard-plugin-wit    1.8.0              pyh44b312d_0    conda-forge
tensorflow                2.4.1           gpu_py38h8a7d6ce_0  
tensorflow-base           2.4.1           gpu_py38h29c2da4_0  
tensorflow-datasets       3.1.0                      py_0    powerai
tensorflow-estimator      2.4.1              pyheb71bc4_0  
tensorflow-gan            2.0.0                      py_0    powerai
tensorflow-gpu            2.4.1                h30adc30_0  
tensorflow-hub            0.8.0              pyh1d8a796_0    powerai
tensorflow-metadata       0.21.0             pyh1d8a796_0    powerai
tensorflow-probability    0.7                        py_2  
termcolor                 1.1.0                      py_2    conda-forge
tk                        8.6.10               h21135ba_1    conda-forge
torchvision               0.8.1                py38_cu101    pytorch
tornado                   6.1              py38h497a2fe_1    conda-forge
tqdm                      4.59.0             pyhd3eb1b0_1  
typing                    3.7.4.3          py38h06a4308_0  
typing-extensions         3.7.4.3                       0    conda-forge
typing_extensions         3.7.4.3                    py_0    conda-forge
urllib3                   1.26.4             pyhd8ed1ab_0    conda-forge
websocket-client          0.57.0           py38h578d9bd_4    conda-forge
werkzeug                  1.0.1              pyh9f0ad1d_0    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
wrapt                     1.12.1           py38h497a2fe_3    conda-forge
wurlitzer                 1.0.3                      py_2    comet_ml
x264                      1!161.3030           h7f98852_0    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.7.0                h7f98852_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h7f98852_1    conda-forge
xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
yarl                      1.6.3            py38h497a2fe_1    conda-forge
zipp                      3.4.1              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h516909a_1010    conda-forge
zstd                      1.4.9                ha95c52a_0    conda-forge
Ian-Mint commented 3 years ago

Fixed with the following change on line 2805 of tensorflow/python/ops/array_ops.py:

-     if np.prod(shape) < 1000:
+     if tf.math.reduce_prod(shape) < 1000: