def __init__(self, dims, n_clusters=4, alpha=1.0): super(IDEC, self).__init__() self.dims = dims self.input_dim = dims[0] self.n_stacks = len(self.dims) - 1 self.n_clusters = n_clusters self.alpha = alpha self.autoencoder = autoencoder(self.dims) hidden = self.autoencoder.get_layer(name='encoder_%d' % (self.n_stacks - 1)).output self.encoder = Model(inputs=self.autoencoder.input, outputs=hidden) # prepare IDEC model clustering_layer = ClusteringLayer(self.n_clusters, alpha=self.alpha, name='clustering')(hidden) self.model = Model(inputs=self.autoencoder.input, outputs=[clustering_layer, self.autoencoder.output]) self.pretrained = False self.centers = [] self.y_pred = []
def __init__(self, dims, n_clusters=10, alpha=1.0, batch_size=256): super(IDEC, self).__init__() self.dims = dims self.input_dim = dims[0] self.n_stacks = len(self.dims) - 1 self.n_clusters = n_clusters self.alpha = alpha self.batch_size = batch_size self.autoencoder = autoencoder(self.dims)
def __init__(self, dims, gamma=0.1, n_clusters=10, alpha=1.0, init='glorot_uniform'): # super(IDEC,self).__init__(dims, # n_clusters=10, # alpha=1.0, # init='glorot_uniform') self.dims = dims self.input_dim = dims[0] self.n_stacks = len(self.dims) - 1 self.n_clusters = n_clusters self.alpha = alpha self.autoencoder, self.encoder = autoencoder(self.dims, init=init) # prepare DEC model clustering_layer = ClusteringLayer(self.n_clusters, name='clustering')( self.encoder.output) self.model = Model(inputs=self.autoencoder.input, outputs=[clustering_layer, self.autoencoder.output])