FlorentF9 / DeepTemporalClustering

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

how to load model.h5 #24

Closed ryan-gz closed 2 years ago

ryan-gz commented 2 years ago

Hi Florent, I've got some doc vectors,and tried to fit the model. Now I got some trained models( named like 'model_40.h5'). I want to see the details of clustering or predict new doc vectors, how could I load these DTC models? Many thanks.

lushunn commented 2 years ago

This is my code

from DeepTemporalClustering import  DTC
from  datasets_ts import  load_data
import numpy as np
dtc = DTC(n_clusters=5,
          input_dim=8,
          timesteps=168,
          n_filters=50,
          kernel_size=10,
          strides=1,
          pool_size=24,
          n_units=[50, 10],
          alpha=1.0,
          dist_metric='eucl',
          cluster_init='kmeans',
          heatmap=True) # same as your training parameters
dtc.initialize()
dtc.load_weights('results/tmp/DTC_model_final.h5')
import joblib
X = joblib.load('./data/X.h5') ## your test data
pred=dtc.predict(X)
ryan-gz commented 2 years ago

@lushunn Thanks! It really helps.