from pyts.transformation import GASF, GADF from pyts import transformation, classification, visualization gasf = GASF(image_size=61, overlapping=False, scale='-1') X_gasf = gasf.transform(X_standardized) X_gasf.ndim #3 Xt_gasf = gasf.transform(Xt_standardized) gadf = GADF(image_size=61, overlapping=False, scale='-1') X_gadf = gadf.transform(X_standardized) Xt_gadf = gadf.transform(Xt_standardized) from pyts.visualization import plot_gasf plot_gasf(X_standardized[0], image_size=61, overlapping=False, scale='-1') from pyts.visualization import plot_gadf plot_gadf(X_standardized[4], image_size=30, overlapping=False, scale='-1') x_train = X_gadf.reshape x_train = X_gadf.reshape(X_gadf.shape[0], 61, 61, 1) x_test = Xt_gadf.reshape(Xt_gadf.shape[0], 61, 61, 1) #----------------------------------------------------------------------------------------------------------------------------------------------------- def auc_roc(y_true, y_pred): # any tensorflow metric value, update_op = tf.contrib.metrics.streaming_auc(y_pred, y_true)
# gasf = GASF(image_size=100, overlapping=False, scale='0') # X_gasf = gasf.transform concerned_layers = [ "conv1d_1", "conv1d_2", "conv1d_3", "conv1d_4", "conv1d_5", "conv1d_6", "conv1d_7", "conv1d_8" ] for concerned_layer in concerned_layers: print concerned_layer layer = model.get_layer(concerned_layer) all_filters = layer.get_weights()[0] reorganized_filters = [] for i in range(num_filters): print i temp_filter = [] for filter in all_filters: temp_filter.append(filter[0][i]) reorganized_filters.append(np.array(temp_filter)) from pyts.visualization import plot_gasf filter_index = 0 for reorganized_filter in reorganized_filters: plot_gasf(reorganized_filter, image_size=kernel_size, overlapping=False, scale='0', output_file="layer_%s_filter%s" % (concerned_layer, filter_index)) filter_index += 1 print("--- train %s seconds ---" % (time.time() - start_time))