shapelet_sizes = sorted(self.n_shapelets_per_size.keys())
pool_layers = []
for i, sz in enumerate(sorted(shapelet_sizes)):
transformer_layer = Conv1D(filters=sz,
kernel_size=sz,
trainable=False,
use_bias=False,
name="false_conv_%d" % i)(inputs)
shapelet_layer = LocalSquaredDistanceLayer(self.n_shapelets_per_size[sz],
name="shapelets_%d" % i)(transformer_layer)
pool_layers.append(GlobalMinPooling1D(name="min_pooling_%d" % i)(shapelet_layer))
if len(shapelet_sizes) > 1:
After Change
self.model.get_layer("false_conv_%d_%d" % (i, di)).set_weights([numpy.eye(sz).reshape((sz, 1, sz))])
def _set_model_layers(self, ts_sz, d, n_classes):
inputs = [Input(shape=(ts_sz, 1), name="input_%d" % di) for di in range(d)]
shapelet_sizes = sorted(self.n_shapelets_per_size.keys())
pool_layers = []
for i, sz in enumerate(sorted(shapelet_sizes)):
transformer_layers = [Conv1D(filters=sz,
kernel_size=sz,
trainable=False,
use_bias=False,
name="false_conv_%d_%d" % (i, di))(inputs[di]) for di in range(d)]
shapelet_layers = [LocalSquaredDistanceLayer(self.n_shapelets_per_size[sz],
name="shapelets_%d_%d" % (i, di))(transformer_layers[di])
for di in range(d)]