Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public DatasetManager(TrainArgs args, string dataset_name, Tuple <List <Array>, NDArray, NDArray> custom_list = null)
        {
            this.args         = args;
            this.dataset_name = dataset_name;
            this.dataset_info = new PredictionDatasetManager().call(dataset_name);

            if (custom_list != null && len(custom_list) == 3)
            {
                this.video_neighbor_list = custom_list.Item1;
                this.video_matrix        = custom_list.Item2;
                this.frame_list          = custom_list.Item3;
            }
            else
            {
                (this.video_neighbor_list, this.video_matrix, this.frame_list) = this.load_data();
            }

            this.all_entire_trajectories = this.prepare_agent_data();
        }
Пример #4
0
        public MapManager(
            TrainArgs args,
            List <TrainAgentManager> agents,
            MapManager init_manager = null
            )
        {
            this.args   = args;
            this.agents = agents;

            if (!(init_manager == null))
            {
                this.void_map = init_manager.void_map;
                this.W        = init_manager.W;
                this.b        = init_manager.b;
            }
            else
            {
                (this.void_map, this.W, this.b) = this.init_guidance_map(agents);
            }
        }
Пример #5
0
 public SatoshiAlpha(
     Prediction.TrainArgs args
     ) : base(args)
 {
     self.gcn_layer_count = self.args.gcn_layers;
 }
 public Structure(TrainArgs args) : base(args)
 {
     this._train_args = args;
 }
 public Model(TrainArgs args, Structure training_structure) : base((BaseArgs)args)
 {
     this._train_args         = args;
     this._training_structure = training_structure;
 }