FlorentF9 / DeepTemporalClustering

:chart_with_upwards_trend: Keras implementation of the Deep Temporal Clustering (DTC) model
MIT License
219 stars 58 forks source link

variable time step #8

Open jzyee opened 4 years ago

jzyee commented 4 years ago

Hi in the documentation for the DTC object, found in DeepTemporalClustering.py, it is indicated that the timesteps param can be variable. However when I instantiate as follows:

dtc = DTC(n_clusters=3, input_dim=X_train.shape[-1], timesteps=None, n_filters=50, kernel_size=10, strides=1, pool_size=None, n_units=[50, 1], alpha=1, dist_metric='eucl', cluster_init='kmeans', heatmap=False)

I get an error. There is an assert which brings up a typeError.

TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

Should I be using 0 instead of None?

FlorentF9 commented 4 years ago

I assume the error is thrown by the pooling layer. You can use variable series length by setting timesteps=None (because the architecture is fully convolutional and recurrent), however you can't set pool_size=None.

jzyee commented 4 years ago

The following lines in DeepTemporalClustering.py throw an error:

Besides lines 55:

assert(timesteps % pool_size == 0)

Line 64:

self.latent_shape = (self.timesteps // self.pool_size, self.n_units[1])

They don't work when I assign timesteps=None

Could you show an example of how you would initiate the DTC object for a variable-length dataset

FlorentF9 commented 3 years ago

You are right, I have to take a look at this when I have time. I keep this issue open for now.

FlorentF9 commented 3 years ago

I took a quick look. Actually I was stuck with the variable timestep because of two things:

In a nutshell, I think the timesteps cannot be variable in DTC. But if anyone has an idea about it, please tell!