Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DEC in TensorFlow 1.3; AttributeError: can't set attribute #8

@NatLun091238

Description

@NatLun091238

Thank you for posting the code! I attempted to implement your code in TF 1.3 making the following changes:

import tensorflow.contrib.keras.api.keras as K
from tensorflow.contrib.keras.api.keras.initializers import RandomNormal
from tensorflow.contrib.keras.api.keras.layers import Layer, InputSpec
from tensorflow.contrib.keras.api.keras.models import Model, Sequential
from tensorflow.contrib.keras.api.keras.layers import Dense, Dropout, Input
from tensorflow.contrib.keras.api.keras.optimizers import SGD
from tensorflow.contrib.keras.api.keras.callbacks import LearningRateScheduler
from tensorflow.contrib.keras.api.keras.backend import floatx

However, I encounter en error message pointing to line#71, which is the last line in the following:

def build(self, input_shape):
        assert len(input_shape) == 2
        input_dim = input_shape[1]
        self.input_spec = [InputSpec(dtype=K.backend.floatx(),
                                     shape=(None, input_dim))]
        
        self.W = K.backend.variable(self.initial_weights) 
        self.trainable_weights = [self.W]

layerwise pretrain and Finetuning autoencoder works fine on the test example (mnist), but then Initializing cluster centres with k-means. crushes with an error message:

self.trainable_weights = K.backend.variable(self.initial_weights)

AttributeError: can't set attribute

What could be the reason for that??? Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions