alecGraves / BVAE-tf

Disentangled Variational Auto-Encoder in TensorFlow / Keras (Beta-VAE)
The Unlicense
54 stars 13 forks source link

Unable to run ae.py due to NoneType error #10

Closed harbarex closed 4 years ago

harbarex commented 4 years ago

I was trying to run the code, and encountered the following error. Please tell me how I can fix it.

Traceback (most recent call last):
  File "ae.py", line 65, in <module>
    test()
  File "ae.py", line 45, in test
    encoder = Darknet19Encoder(inputShape, latentSize=latentSize, latentConstraints='bvae', beta=69)
  File "/home/ies/billa/BVAE-tf/bvae/models.py", line 72, in __init__
    super().__init__(inputShape, batchSize, latentSize)
  File "/home/ies/billa/BVAE-tf/bvae/models.py", line 41, in __init__
    self.model = self.Build()
  File "/home/ies/billa/BVAE-tf/bvae/models.py", line 114, in Build
    sample = SampleLayer(self.latentConstraints, self.beta)([mean, logvar], training=self.training)
  File "/home/ies/billa/miniconda3/envs/pfprint/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 922, in __call__
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "/home/ies/billa/miniconda3/envs/pfprint/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py", line 265, in wrapper
    raise e.ag_error_metadata.to_exception(e)
AttributeError: in user code:

    /home/ies/billa/BVAE-tf/bvae/sample_layer.py:70 call  *
        if mean.shape[0].value == None or  logvar.shape[0].value == None:

    AttributeError: 'NoneType' object has no attribute 'value'
harbarex commented 4 years ago

The issue was fixed by replacing line 70 in sample_layer.py

if mean.shape[0].value == None or logvar.shape[0].value == None:

by

if mean.shape[0] == None or logvar.shape[0] == None:

I am using tensorflow 2.2.0, with cudnn 7.6.5 and cudatoolkit 10.1, hence it might've just been a syntax error.