Пример #1
0
    def __init__(self, n_out = 3, n_sigs=2, K=[1,2,3], agg_method='sum', hidden_states=64, glob=True, conv_layers=1, conv_activation='relu', decode_layers=2, decode_activation=1, regularization=None, dropout=0.2, batch_norm=True, forward=True):
        super().__init__()
        self.n_out=n_out
        self.n_sigs=n_sigs
        self.hidden_states=hidden_states
        self.conv_activation=conv_activation
        self.forward=forward
        self.dropout=dropout
        self.glob=glob
        self.Ks=K
        self.agg_method=agg_method
        self.conv_layers=conv_layers
        self.regularize=regularization
        if type(decode_activation)==str:
          self.decode_activation=tf.keras.activations.get(decode_activation)
        else:
          self.decode_activation=d_act
        self.batch_norm=batch_norm
        # Define layers of the model

        self.MPs      = [SGConv(hidden_states, hidden_states, K=K, agg_method=self.agg_method, dropout = dropout) for K in self.Ks]

        self.GCNs    = [GraphSageConv(hidden_states*int(i), activation=self.conv_activation, kernel_regularizer=self.regularize) for i in 2*2**np.arange(self.conv_layers)]

        self.Pool1   = GlobalMaxPool()
        self.Pool2   = GlobalAvgPool()
        self.Pool3   = GlobalSumPool()

        self.decode  = [Dense(i * hidden_states) for i in  2*2**np.arange(decode_layers+1,1,-1)]
        self.dropout_layers  = [Dropout(dropout) for i in range(len(self.decode))]
        if self.batch_norm:
          self.norm_layers  = [BatchNormalization() for i in range(len(self.decode))]
        else:
          self.norm_layers =  [no_norm for i in range(len(self.decode))]
        
        self.loge     = [Dense(hidden_states) for _ in range(2)]
        self.loge_out = Dense(1)
        self.angles     = [Dense(hidden_states) for _ in range(2)]
        self.angles_out = Dense(2)
        self.angle_scale= Dense(2)
        if n_sigs > 0:
          self.sigs      = [Dense(hidden_states) for i in range(2)]
          self.sigs_out  = Dense(n_sigs)
Пример #2
0
 def __init__(self, n_out=7):
     super().__init__()
     # Define layers of the model
     self.ECC1 = ECCConv(hidden_states,
                         [hidden_states, hidden_states, hidden_states],
                         n_out=hidden_states,
                         activation="relu")
     self.GCS1 = GCSConv(hidden_states, activation="relu")
     self.GCS2 = GCSConv(hidden_states * 2, activation="relu")
     self.GCS3 = GCSConv(hidden_states * 4, activation="relu")
     self.GCS4 = GCSConv(hidden_states * 8, activation="relu")
     self.Pool1 = GlobalMaxPool()
     self.Pool2 = GlobalAvgPool()
     self.Pool3 = GlobalSumPool()
     self.decode = [
         Dense(size * hidden_states) for size in [16, 8, 4, 2, 2]
     ]
     self.norm_layers = [
         BatchNormalization() for i in range(len(self.decode))
     ]
     self.d2 = Dense(n_out)
Пример #3
0
    def __init__(self,
                 n_out=3,
                 n_sigs=2,
                 hidden_states=64,
                 conv_layers=2,
                 decode_layers=3,
                 conv_activation='relu',
                 decode_activation=1,
                 regularization=None,
                 dropout=0.03):
        super().__init__()
        self.n_out = n_out
        self.n_sigs = n_sigs
        self.hidden_states = hidden_states
        self.conv_activation = conv_activation
        self.dropout = dropout
        self.conv_layers = conv_layers
        self.regularize = regularization
        if type(decode_activation) == str:
            self.decode_activation = tf.keras.activations.get(
                decode_activation)
        else:
            self.decode_activation = d_act

        # Define layers of the model

        self.hop2mean = SGConv(hidden_states,
                               hidden_states,
                               K=2,
                               agg_method='mean',
                               dropout=dropout)

        self.norm_edge = BatchNormalization()

        self.GCNs = [
            GraphSageConv(hidden_states * int(i),
                          activation=self.conv_activation,
                          kernel_regularizer=self.regularize)
            for i in 2 * 2**np.arange(self.conv_layers)
        ]

        self.Pool1 = GlobalMaxPool()
        self.Pool2 = GlobalAvgPool()
        self.Pool3 = GlobalSumPool()

        self.decode = [
            Dense(int(i) * hidden_states)
            for i in 1.5 * 2**np.arange(decode_layers + 1, 1, -1)
        ]
        self.dropout_layers = [
            Dropout(dropout) for i in range(len(self.decode))
        ]
        self.norm_layers = [
            BatchNormalization() for i in range(len(self.decode))
        ]

        self.loge = [Dense(hidden_states) for _ in range(2)]
        self.loge_out = Dense(1)
        self.angles = [Dense(hidden_states) for _ in range(2)]
        self.angles_out = Dense(2)
        self.angle_scale = Dense(2)

        self.sigs = [Dense(hidden_states) for i in range(2)]
        self.sigs_out = Dense(n_sigs)
Пример #4
0
    def __init__(self,
                 n_out=3,
                 n_sigs=2,
                 hidden_states=64,
                 conv_layers=2,
                 glob=True,
                 conv_activation='relu',
                 decode_layers=3,
                 decode_activation=d_act,
                 regularization=None,
                 dropout=0.2,
                 batch_norm=True,
                 forward=True,
                 edgeconv=True):
        super().__init__()
        self.n_out = n_out
        self.n_sigs = n_sigs
        self.hidden_states = hidden_states
        self.conv_activation = conv_activation
        self.forward = forward
        self.dropout = dropout
        self.glob = glob
        self.conv_layers = conv_layers
        self.edgeconv = edgeconv
        self.regularize = regularization
        if type(decode_activation) == str:
            self.decode_activation = tf.keras.activations.get(
                decode_activation)
        else:
            self.decode_activation = d_act
        self.batch_norm = batch_norm
        # Define layers of the model
        if self.edgeconv:
            self.ECC1 = ECCConv(hidden_states,
                                [hidden_states, hidden_states, hidden_states],
                                n_out=hidden_states,
                                activation="relu",
                                kernel_regularizer=self.regularize)
        self.GCNs = [
            GCNConv(hidden_states * int(i),
                    activation=self.conv_activation,
                    kernel_regularizer=self.regularize)
            for i in 2**np.arange(self.conv_layers)
        ]
        self.Pool1 = GlobalMaxPool()
        self.Pool2 = GlobalAvgPool()
        self.Pool3 = GlobalSumPool()

        self.decode = [
            Dense(i * hidden_states) for i in 2 * 2**np.arange(decode_layers)
        ]
        self.dropout_layers = [
            Dropout(dropout) for i in range(len(self.decode))
        ]
        if self.batch_norm:
            self.norm_layers = [
                BatchNormalization() for i in range(len(self.decode))
            ]
        else:
            self.norm_layers = [no_norm for i in range(len(self.decode))]

        self.loge = [Dense(hidden_states) for _ in range(2)]
        self.loge_out = Dense(1)
        self.angles = [Dense(hidden_states) for _ in range(2)]
        self.angles_out = Dense(2)
        self.angle_scale = Dense(2)
        if n_sigs > 0:
            self.sigs = [Dense(hidden_states) for i in range(2)]
            self.sigs_out = Dense(n_sigs)