def __init__(self,
                 fm_infile,
                 seed_hv_infile,
                 num_folds,
                 is_early_fusion=True):

        # Feature Memory
        self.feature_memory = memory.FeatureMemory(fm_infile)
        self.feature_memory.normalize()
        self.feature_memory.downSample(self.downsample_interval)
        self.feature_memory.discretize()
        self.feature_memory.genTrainData(self.learning_rate)

        # Seed HV progress over time
        self.seed_hv = memory.Memory(seed_hv_infile).getRow(0).tolist()

        # Associative Memory
        memory.AssociativeMemory.dimension = self.dimension
        self.associative_memory = memory.AssociativeMemory()

        # Spatial Encoder
        spatial_encoder.SpatialEncoder.dimension = self.dimension
        self.spatial_encoder_GSR = spatial_encoder.SpatialEncoder(
            self.num_channel_GSR)
        self.spatial_encoder_ECG = spatial_encoder.SpatialEncoder(
            self.num_channel_ECG)
        self.spatial_encoder_EEG = spatial_encoder.SpatialEncoder(
            self.num_channel_EEG)

        # Temporal Encoder
        temporal_encoder.TemporalEncoder.dimension = self.dimension
        temporal_encoder.TemporalEncoder.ngram_size = self.ngram_size
        self.temporal_encoder = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is True
        self.temporal_encoder_GSR = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is False
        self.temporal_encoder_ECG = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is False
        self.temporal_encoder_EEG = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is False

        self.is_early_fusion = is_early_fusion

        self.num_folds = num_folds

        # Prediction Statistics
        self.correct_prediction = 0
        self.wrong_prediction = 0
        self.prediction_success_rate = 0

        self.correct_v_prediction = 0
        self.wrong_v_prediction = 0
        self.prediction_v_success_rate = 0

        self.correct_a_prediction = 0
        self.wrong_a_prediction = 0
        self.prediction_a_success_rate = 0

        self.predicted_v_history = []
        self.predicted_a_history = []
예제 #2
0
    def __init__(self,
                 fm_infile,
                 pm_plus_GSR_infile,
                 pm_neg_GSR_infile,
                 pm_plus_ECG_infile,
                 pm_neg_ECG_infile,
                 pm_plus_EEG_infile,
                 pm_neg_EEG_infile,
                 im_infile,
                 is_early_fusion=True):

        # Feature Memory
        self.feature_memory = memory.FeatureMemory(fm_infile)
        self.feature_memory.normalize()
        self.feature_memory.downSample(self.downsample_interval)
        self.feature_memory.discretize()
        self.feature_memory.genTrainData(self.learning_rate)

        # Projection Memory
        self.projection_memory_GSR = memory.ProjectionMemory(
            pm_plus_GSR_infile, pm_neg_GSR_infile)
        self.projection_memory_ECG = memory.ProjectionMemory(
            pm_plus_ECG_infile, pm_neg_ECG_infile)
        self.projection_memory_EEG = memory.ProjectionMemory(
            pm_plus_EEG_infile, pm_neg_EEG_infile)

        # Item Memory
        self.item_memory = memory.Memory(im_infile)

        # Associative Memory
        memory.AssociativeMemory.dimension = self.dimension
        self.associative_memory = memory.AssociativeMemory()

        # Spatial Encoder
        spatial_encoder.SpatialEncoder.dimension = self.dimension
        self.spatial_encoder_GSR = spatial_encoder.SpatialEncoder(
            self.num_channel_GSR)
        self.spatial_encoder_ECG = spatial_encoder.SpatialEncoder(
            self.num_channel_ECG)
        self.spatial_encoder_EEG = spatial_encoder.SpatialEncoder(
            self.num_channel_EEG)

        # Temporal Encoder
        temporal_encoder.TemporalEncoder.dimension = self.dimension
        temporal_encoder.TemporalEncoder.ngram_size = self.ngram_size
        self.temporal_encoder = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is True
        self.temporal_encoder_GSR = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is False
        self.temporal_encoder_ECG = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is False
        self.temporal_encoder_EEG = temporal_encoder.TemporalEncoder(
        )  # used only when is_early_fusion is False

        self.is_early_fusion = is_early_fusion

        # Prediction Statistics
        self.correct_prediction = 0
        self.wrong_prediction = 0
        self.prediction_success_rate = 0

        self.correct_v_prediction = 0
        self.wrong_v_prediction = 0
        self.prediction_v_success_rate = 0

        self.correct_a_prediction = 0
        self.wrong_a_prediction = 0
        self.prediction_a_success_rate = 0

        self.predicted_v_history = []
        self.predicted_a_history = []