Simplicity
Simplicity

Reputation: 48916

Keras/Tensorflow - TypeError: __init__() got an unexpected keyword argument 'rescale'

In the following line of code:

datagen = ImageDataGenerator(rescale=1./255)

I'm getting this error:

TypeError: __init__() got an unexpected keyword argument 'rescale'

Provided that I'm using Keras v.1.0.3 with a Tensorflow backend. I'm using TensorFlow v.1.0.0.

Using the latest version of Keras will cause me the issue below, which is why I'm avoiding using the latest version:

KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')"

The latter issue seems to be related to this code snippet:

# load VGG16 weights
    f = h5py.File(weights_path)

    for k in range(f.attrs['nb_layers']):
        if k >= len(model.layers):
            break
        g = f['layer_{}'.format(k)]
        weights = [g['param_{}'.format(p)] for p in range(g.attrs['nb_params'])]
        model.layers[k].set_weights(weights)

    f.close()
    print('Model loaded.')

How can I solve this rescale issue, or even the latter issue if that would work?

Thanks.

Upvotes: 2

Views: 2781

Answers (1)

Simplicity
Simplicity

Reputation: 48916

Updating to the latest Keras and Tensorflow versions solved the issue.

Upvotes: 1

Related Questions