public SatoshiAlphaModel( Prediction.TrainArgs args, Prediction.Structure training_structure = null, int gcn_layer_count = 2, int intention_count = 10 ) : base(args, training_structure) { self.gcn_layer_count = gcn_layer_count; self.intention_count = intention_count; // GCN layers self.pos_embadding = keras.layers.Dense(64, activation: tf.nn.tanh); self.adj_dense = keras.layers.Dense(self.args.obs_frames, activation: tf.nn.tanh); foreach (var count in range(self.gcn_layer_count)) { self.gcn_layers[string.Format("{0}", count)] = GraphConv_layer(64, activation: count < self.gcn_layer_count - 1 ? tf.nn.relu : tf.nn.tanh); } self.gcn_dropout = keras.layers.Dropout(self.args.dropout); self.gcn_bn = keras.layers.BatchNormalization(); self.adj_dense2 = keras.layers.Dense(self.intention_count, activation: tf.nn.tanh); self.gcn_transfer = GraphConv_layer(64, tf.nn.tanh); // context feature self.average_pooling = keras.layers.MaxPooling2D((5, 5)); self.flatten = keras.layers.Flatten(); self.context_dense1 = keras.layers.Dense(self.intention_count * 64, activation: tf.nn.tanh); // decoder self.concat = keras.layers.Concatenate(); self.decoder = keras.layers.Dense(2); }
public LinearModel( Prediction.TrainArgs args, Prediction.Structure training_structure = null ) : base(args, training_structure) { Tensor P; var diff_weights = this.args.diff_weights; if (diff_weights == 0) { P = tf.diag(tf.ones(this.args.obs_frames)); } else { P = tf.diag(tf.nn.softmax( tf.pow(tf.cast(tf.range(1, 1 + this.args.obs_frames), tf.float32), diff_weights) )); } this.x = tf.cast(np.arange(this.args.obs_frames), tf.float32); this.x_p = tf.cast(np.arange(this.args.pred_frames) + this.args.obs_frames, tf.float32); var A = tf.transpose(tf.stack(new Tensor[] { tf.ones((this.args.obs_frames), dtype: tf.float32), this.x })); this.A_p = tf.transpose(tf.stack(new Tensor[] { tf.ones((this.args.pred_frames), dtype: tf.float32), this.x_p })); this.W = tf.matmul(tf.matmul(ndarray_inv((tf.matmul(tf.matmul(tf.transpose(A), P), A)).numpy()).astype(np.float32), tf.transpose(A)), P); }
public Model(TrainArgs args, Structure training_structure) : base((BaseArgs)args) { this._train_args = args; this._training_structure = training_structure; }