Ejemplo n.º 1
0
        void SendBufferUpdate(object param)
        {
            if (!TrialInformation.IsFullFeatured)
            {
                TrialInformation.ShowBuyDialog();
                return;
            }

            if (Config.BufferProfiles.Count == 0)
            {
                AskBufferLogin();
                return;
            }

            List <string> profiles = new List <string>();

            foreach (var account in SelectedAccounts.Cast <UserToken>())
            {
                var profile = Config.BufferProfiles.Where(x => x.ServiceUsername == account.ScreenName).FirstOrDefault();

                if (profile != null)
                {
                    profiles.Add(profile.Id);
                }
            }

            var service = ServiceDispatcher.GetBufferService();

            if (service != null)
            {
                IsLoading = true;
                service.PostUpdate(TweetText, profiles, ReceiveBufferResponse);
            }
        }
Ejemplo n.º 2
0
        private void ProcessThread()
        {
            for (int batchIndex = currentBathDataIndex; batchIndex < batchDataList.Count; batchIndex++)
            {
                learningStatus = LearningStatus.Training;

                currentBathDataIndex = batchIndex;

                simulator         = batchDataList[batchIndex].Simulator;
                learningSetupList = batchDataList[batchIndex].LearningSetupList;

                simulator.UseActivationInformation = saveLayerActivationCheckBox.Checked;
                simulator.UseWeightInformation     = saveWeightCheckBox.Checked;

                this.Invoke(new MethodInvoker(delegate
                {
                    BatchListBoxRefresh();
                    TestDisplayRefresh();
                }));

                for (int learningSetupIndex = currentLearningSetupIndex; learningSetupIndex < learningSetupList.Count; learningSetupIndex++)
                {
                    totalEpoch = 0;
                    for (int i = 0; i < learningSetupIndex; i++)
                    {
                        totalEpoch += learningSetupList[i].TrainingEpoch;
                    }

                    currentLearningSetupIndex = learningSetupIndex;
                    List <MatchingInformation> currentTrainingMatchingInformationList = learningSetupList[learningSetupIndex].TrainingMatchingInformationList;
                    List <MatchingInformation> currentTestMatchingInformationList     = learningSetupList[learningSetupIndex].TestMatchingInformationList;

                    List <TrialInformation> testMatrixTrialInformationList = new List <TrialInformation>();
                    foreach (MatchingInformation testMatchingInformation in currentTestMatchingInformationList)
                    {
                        bool isSRN = false;
                        foreach (Order order in simulator.ProcessDictionary[testMatchingInformation.ProcessName])
                        {
                            if (order.Code == OrderCode.SRNTraining || order.Code == OrderCode.SRNTest)
                            {
                                isSRN = true;
                            }
                        }

                        List <StimuliMatrix> stimuliMatrixList;
                        if (isSRN && learningSetupList[learningSetupIndex].MatrixCalculationSize == 1)
                        {
                            stimuliMatrixList = simulator.StimuliPackDictionary[testMatchingInformation.StimuliPackName].GetMatrixStimuliData(true, true, 1);
                        }
                        else
                        {
                            stimuliMatrixList = simulator.StimuliPackDictionary[testMatchingInformation.StimuliPackName].GetMatrixStimuliData(false, false, simulator.StimuliPackDictionary[testMatchingInformation.StimuliPackName].Count);
                        }
                        foreach (StimuliMatrix stimuliMatrix in stimuliMatrixList)
                        {
                            TrialInformation newTestTrialInformation = new TrialInformation();
                            newTestTrialInformation.Process       = simulator.ProcessDictionary[testMatchingInformation.ProcessName];
                            newTestTrialInformation.PatternSetup  = testMatchingInformation.PatternSetup;
                            newTestTrialInformation.StimuliMatrix = stimuliMatrix;

                            testMatrixTrialInformationList.Add(newTestTrialInformation);
                        }
                    }

                    if (currentEpoch == 0)
                    {
                        learningStatus = LearningStatus.Test;
                        if (simulator.UseWeightInformation)
                        {
                            simulator.WeightInformationReader(totalEpoch + 0);
                        }
                        for (int testIndex = 0; testIndex < testMatrixTrialInformationList.Count; testIndex++)
                        {
                            simulator.Process(testMatrixTrialInformationList[testIndex], totalEpoch + 0);
                        }
                    }

                    for (int epochIndex = currentEpoch; epochIndex < learningSetupList[learningSetupIndex].TrainingEpoch; epochIndex++)
                    {
                        learningStatus = LearningStatus.Training;

                        currentTick = DateTime.Now.Ticks;

                        currentEpoch = epochIndex;

                        List <TrialInformation> trainingMatrixTrialInformationList = new List <TrialInformation>();
                        foreach (MatchingInformation trainingMatchingInformation in currentTrainingMatchingInformationList)
                        {
                            List <StimuliMatrix> stimuliMatrixList = new List <StimuliMatrix>();
                            switch (learningSetupList[learningSetupIndex].TrainingProcessMode)
                            {
                            case ProcessMode.RandomAll:
                            case ProcessMode.RandomInStimuliPack:
                                stimuliMatrixList = simulator.StimuliPackDictionary[trainingMatchingInformation.StimuliPackName].GetMatrixStimuliData(true, true, learningSetupList[learningSetupIndex].MatrixCalculationSize);
                                break;

                            case ProcessMode.SequentialAll:
                            case ProcessMode.SequentialinStimuliPack:
                                stimuliMatrixList = simulator.StimuliPackDictionary[trainingMatchingInformation.StimuliPackName].GetMatrixStimuliData(true, false, learningSetupList[learningSetupIndex].MatrixCalculationSize);
                                break;
                            }

                            foreach (StimuliMatrix stimuliMatrix in stimuliMatrixList)
                            {
                                TrialInformation newTrainingTrialInformation = new TrialInformation();
                                newTrainingTrialInformation.Process       = simulator.ProcessDictionary[trainingMatchingInformation.ProcessName];
                                newTrainingTrialInformation.PatternSetup  = trainingMatchingInformation.PatternSetup;
                                newTrainingTrialInformation.StimuliMatrix = stimuliMatrix;

                                trainingMatrixTrialInformationList.Add(newTrainingTrialInformation);
                            }
                        }

                        switch (learningSetupList[learningSetupIndex].TrainingProcessMode)
                        {
                        case ProcessMode.RandomAll:
                        case ProcessMode.SequentialinStimuliPack:
                            trainingMatrixTrialInformationList = trainingMatrixTrialInformationList.OrderBy(x => (SimulatorAccessor.random.Next())).ToList();
                            break;
                        }

                        currentTrialInformationCount = trainingMatrixTrialInformationList.Count;
                        for (int trainingIndex = 0; trainingIndex < trainingMatrixTrialInformationList.Count; trainingIndex++)
                        {
                            currentProcessName     = trainingMatrixTrialInformationList[trainingIndex].Process.Name;
                            currentStimuliPackName = trainingMatrixTrialInformationList[trainingIndex].StimuliMatrix.PackName;
                            simulator.Process(trainingMatrixTrialInformationList[trainingIndex], totalEpoch + epochIndex + 1);
                            currentTrainingIndex = trainingIndex;
                        }

                        if ((epochIndex + 1) % learningSetupList[learningSetupIndex].TestTiming == 0)
                        {
                            learningStatus = LearningStatus.Test;
                            if (simulator.UseWeightInformation)
                            {
                                simulator.WeightInformationReader(totalEpoch + epochIndex + 1);
                            }
                            for (int testIndex = 0; testIndex < testMatrixTrialInformationList.Count; testIndex++)
                            {
                                simulator.Process(testMatrixTrialInformationList[testIndex], totalEpoch + epochIndex + 1);
                            }

                            try { this.Invoke(new MethodInvoker(delegate { TestDisplayRefresh(); })); }
                            catch { }
                        }

                        if (learningStatus == LearningStatus.Pausing)
                        {
                            currentEpoch = epochIndex + 1;
                            break;
                        }

                        currentTick = DateTime.Now.Ticks;
                    }

                    if (learningStatus == LearningStatus.Pausing)
                    {
                        if (currentEpoch >= learningSetupList[learningSetupIndex].TrainingEpoch)
                        {
                            currentEpoch = 0;
                            currentLearningSetupIndex = learningSetupIndex + 1;
                        }
                        if (currentLearningSetupIndex >= learningSetupList.Count)
                        {
                            currentLearningSetupIndex = 0;
                            currentBathDataIndex      = batchIndex + 1;
                        }
                        break;
                    }
                    else
                    {
                        string resultPath = simulator.OutputResult();
                        simulator.WeightSave(resultPath + "Status.WDATA");

                        currentLearningSetupIndex = 0;
                        currentEpoch = 0;
                        totalEpoch   = 0;
                    }
                }
                if (learningStatus == LearningStatus.Pausing)
                {
                    learningStatus = LearningStatus.Paused;
                    break;
                }
            }
            if (learningStatus == LearningStatus.Training || learningStatus == LearningStatus.Test)
            {
                learningStatus = LearningStatus.End;
            }
        }
Ejemplo n.º 3
0
        public DefaultModel()
            : base("Default")
        {
            SelectedFontSize = FontSizeToIndex(((GlobalSettings)App.Current.Resources["GlobalSettings"]).
                                               TweetFontSize);
            RetweetsAsMentions    = Config.RetweetAsMentions == true;
            BackgroundUpdateTiles = Config.BackgroundLoadColumns == true;
            if (Config.TweetsPerRequest == null)
            {
                Config.TweetsPerRequest = 40;
            }
            TweetsPerRequest = Config.TweetsPerRequest.ToString();
            Accounts         = new SafeObservable <UserToken>(Config.Accounts);
            NotifyOptions    = new List <string> {
                Resources.None, Resources.OnlyTile, Resources.ToastAndTile
            };
            SelectedMuteTime         = TimeSpanToSelectedFilter((TimeSpan)Config.DefaultMuteTime);
            ShowResumePositionButton = Config.RecoverReadPositions == true;
            GeoTaggingEnabled        = Config.EnabledGeolocation == true;
            SelectedReloadOption     = (int)Config.ReloadOptions;

            PushAvailable = TrialInformation.IsFullFeatured;

            PushEnabled = PushAvailable && (Config.PushEnabled == true);

            if (Config.ReadLaterCredentials.Instapaper != null)
            {
                InstapaperUser     = Config.ReadLaterCredentials.Instapaper.User;
                InstapaperPassword = Config.ReadLaterCredentials.Instapaper.Password;
            }

            if (Config.ReadLaterCredentials.Pocket != null)
            {
                PocketUser     = Config.ReadLaterCredentials.Pocket.User;
                PocketPassword = Config.ReadLaterCredentials.Pocket.Password;
            }

            this.PropertyChanged += (sender, e) =>
            {
                switch (e.PropertyName)
                {
                case "RetweetsAsMentions":
                    Config.RetweetAsMentions = RetweetsAsMentions;
                    break;

                case "BackgroundUpdateTiles":
                    Config.BackgroundLoadColumns = BackgroundUpdateTiles;
                    break;

                case "TweetsPerRequest":
                    int number;
                    if (int.TryParse(TweetsPerRequest, out number))
                    {
                        Config.TweetsPerRequest = number;
                    }
                    break;

                case "SelectedAccount":
                    if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count)
                    {
                        int newOption;

                        newOption = (int)Config.Accounts[SelectedAccount].Preferences.MentionsPreferences;
                        if (newOption != MentionNotifyOption)
                        {
                            mentionFirstChange  = true;
                            MentionNotifyOption = newOption;
                        }

                        newOption = (int)Config.Accounts[SelectedAccount].Preferences.MessagesPreferences;
                        if (newOption != MessageNotifyOption)
                        {
                            messageFirstChange  = true;
                            MessageNotifyOption = newOption;
                        }
                    }
                    break;

                case "MentionNotifyOption":
                    if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count)
                    {
                        SetMentionNotifyPref((NotificationType)MentionNotifyOption, SelectedAccount);
                    }
                    break;

                case "MessageNotifyOption":
                    if (SelectedAccount >= 0 && SelectedAccount < Config.Accounts.Count)
                    {
                        SetMessageNotifyPref((NotificationType)MessageNotifyOption, SelectedAccount);
                    }
                    Config.SaveAccounts();
                    break;

                case "SelectedMuteTime":
                    Config.DefaultMuteTime = SelectedFilterToTimeSpan(SelectedMuteTime);
                    break;

                case "SelectedFontSize":
                    ((GlobalSettings)App.Current.Resources["GlobalSettings"]).
                    TweetFontSize = IndexToFontSize(SelectedFontSize);
                    break;

                case "ShowResumePositionButton":
                    Config.RecoverReadPositions = ShowResumePositionButton;
                    break;

                case "GeoTaggingEnabled":
                    Config.EnabledGeolocation = GeoTaggingEnabled;
                    break;

                case "PushEnabled":
                    if (!TrialInformation.IsFullFeatured)
                    {
                        if (PushEnabled)
                        {
                            TrialInformation.ShowBuyDialog();
                            PushEnabled = false;
                        }
                        return;
                    }

                    Config.PushEnabled = PushEnabled;
                    if (PushEnabled == false)
                    {
                        PushNotifications.UnregisterAll();
                    }
                    else
                    {
                        PushNotifications.AutoRegisterForNotifications();
                    }
                    break;

                case "SelectedReloadOption":
                    Config.ReloadOptions = (ColumnReloadOptions)SelectedReloadOption;
                    break;
                }
            };

            SelectedAccount = -1;
            if (Config.Accounts.Count > 0)
            {
                SelectedAccount = 0;
            }
            SetCommands();
        }
Ejemplo n.º 4
0
        private void ProcessThread()
        {
            for (int batchIndex = currentBathDataIndex; batchIndex < batchDataList.Count; batchIndex++)
            {
                learningStatus = LearningStatus.Training;

                currentBathDataIndex = batchIndex;

                simulator = batchDataList[batchIndex].Simulator;
                learningSetupList = batchDataList[batchIndex].LearningSetupList;

                simulator.UseActivationInformation = saveLayerActivationCheckBox.Checked;
                simulator.UseWeightInformation = saveWeightCheckBox.Checked;

                this.Invoke(new MethodInvoker(delegate
                {
                    BatchListBoxRefresh();
                    TestDisplayRefresh();
                }));

                for (int learningSetupIndex = currentLearningSetupIndex; learningSetupIndex < learningSetupList.Count; learningSetupIndex++)
                {
                    totalEpoch = 0;
                    for (int i = 0; i < learningSetupIndex; i++) totalEpoch += learningSetupList[i].TrainingEpoch;

                    currentLearningSetupIndex = learningSetupIndex;
                    List<MatchingInformation> currentTrainingMatchingInformationList = learningSetupList[learningSetupIndex].TrainingMatchingInformationList;
                    List<MatchingInformation> currentTestMatchingInformationList = learningSetupList[learningSetupIndex].TestMatchingInformationList;

                    List<TrialInformation> testMatrixTrialInformationList = new List<TrialInformation>();
                    foreach (MatchingInformation testMatchingInformation in currentTestMatchingInformationList)
                    {
                        bool isSRN = false;
                        foreach (Order order in simulator.ProcessDictionary[testMatchingInformation.ProcessName])
                        {
                            if (order.Code == OrderCode.SRNTraining || order.Code == OrderCode.SRNTest) isSRN = true;
                        }

                        List<StimuliMatrix> stimuliMatrixList;
                        if (isSRN && learningSetupList[learningSetupIndex].MatrixCalculationSize == 1) stimuliMatrixList = simulator.StimuliPackDictionary[testMatchingInformation.StimuliPackName].GetMatrixStimuliData(true, true, 1);
                        else stimuliMatrixList = simulator.StimuliPackDictionary[testMatchingInformation.StimuliPackName].GetMatrixStimuliData(false, false, simulator.StimuliPackDictionary[testMatchingInformation.StimuliPackName].Count);
                        foreach (StimuliMatrix stimuliMatrix in stimuliMatrixList)
                        {
                            TrialInformation newTestTrialInformation = new TrialInformation();
                            newTestTrialInformation.Process = simulator.ProcessDictionary[testMatchingInformation.ProcessName];
                            newTestTrialInformation.PatternSetup = testMatchingInformation.PatternSetup;
                            newTestTrialInformation.StimuliMatrix = stimuliMatrix;

                            testMatrixTrialInformationList.Add(newTestTrialInformation);
                        }
                    }

                    if (currentEpoch == 0)
                    {
                        learningStatus = LearningStatus.Test;
                        if (simulator.UseWeightInformation) simulator.WeightInformationReader(totalEpoch + 0);
                        for (int testIndex = 0; testIndex < testMatrixTrialInformationList.Count; testIndex++)
                        {
                            simulator.Process(testMatrixTrialInformationList[testIndex], totalEpoch + 0);
                        }

                    }

                    for (int epochIndex = currentEpoch; epochIndex < learningSetupList[learningSetupIndex].TrainingEpoch; epochIndex++)
                    {
                        learningStatus = LearningStatus.Training;

                        currentTick = DateTime.Now.Ticks;

                        currentEpoch = epochIndex;

                        List<TrialInformation> trainingMatrixTrialInformationList = new List<TrialInformation>();
                        foreach (MatchingInformation trainingMatchingInformation in currentTrainingMatchingInformationList)
                        {
                            List<StimuliMatrix> stimuliMatrixList = new List<StimuliMatrix>();
                            switch (learningSetupList[learningSetupIndex].TrainingProcessMode)
                            {
                                case ProcessMode.RandomAll:
                                case ProcessMode.RandomInStimuliPack:
                                    stimuliMatrixList = simulator.StimuliPackDictionary[trainingMatchingInformation.StimuliPackName].GetMatrixStimuliData(true, true, learningSetupList[learningSetupIndex].MatrixCalculationSize);
                                    break;
                                case ProcessMode.SequentialAll:
                                case ProcessMode.SequentialinStimuliPack:
                                    stimuliMatrixList = simulator.StimuliPackDictionary[trainingMatchingInformation.StimuliPackName].GetMatrixStimuliData(true, false, learningSetupList[learningSetupIndex].MatrixCalculationSize);
                                    break;
                            }

                            foreach (StimuliMatrix stimuliMatrix in stimuliMatrixList)
                            {
                                TrialInformation newTrainingTrialInformation = new TrialInformation();
                                newTrainingTrialInformation.Process = simulator.ProcessDictionary[trainingMatchingInformation.ProcessName];
                                newTrainingTrialInformation.PatternSetup = trainingMatchingInformation.PatternSetup;
                                newTrainingTrialInformation.StimuliMatrix = stimuliMatrix;

                                trainingMatrixTrialInformationList.Add(newTrainingTrialInformation);
                            }
                        }

                        switch (learningSetupList[learningSetupIndex].TrainingProcessMode)
                        {
                            case ProcessMode.RandomAll:
                            case ProcessMode.SequentialinStimuliPack:
                                trainingMatrixTrialInformationList = trainingMatrixTrialInformationList.OrderBy(x => (SimulatorAccessor.random.Next())).ToList();
                                break;
                        }

                        currentTrialInformationCount = trainingMatrixTrialInformationList.Count;
                        for (int trainingIndex = 0; trainingIndex < trainingMatrixTrialInformationList.Count; trainingIndex++)
                        {
                            currentProcessName = trainingMatrixTrialInformationList[trainingIndex].Process.Name;
                            currentStimuliPackName = trainingMatrixTrialInformationList[trainingIndex].StimuliMatrix.PackName;
                            simulator.Process(trainingMatrixTrialInformationList[trainingIndex], totalEpoch + epochIndex + 1);
                            currentTrainingIndex = trainingIndex;
                        }

                        if ((epochIndex + 1) % learningSetupList[learningSetupIndex].TestTiming == 0)
                        {
                            learningStatus = LearningStatus.Test;
                            if (simulator.UseWeightInformation) simulator.WeightInformationReader(totalEpoch + epochIndex + 1);
                            for (int testIndex = 0; testIndex < testMatrixTrialInformationList.Count; testIndex++)
                            {
                                simulator.Process(testMatrixTrialInformationList[testIndex], totalEpoch + epochIndex + 1);
                            }

                            try { this.Invoke(new MethodInvoker(delegate { TestDisplayRefresh(); })); }
                            catch { }
                        }

                        if (learningStatus == LearningStatus.Pausing)
                        {
                            currentEpoch = epochIndex + 1;
                            break;
                        }

                        currentTick = DateTime.Now.Ticks;
                    }

                    if (learningStatus == LearningStatus.Pausing)
                    {
                        if (currentEpoch >= learningSetupList[learningSetupIndex].TrainingEpoch)
                        {
                            currentEpoch = 0;
                            currentLearningSetupIndex = learningSetupIndex + 1;
                        }
                        if(currentLearningSetupIndex >= learningSetupList.Count)
                        {
                            currentLearningSetupIndex = 0;
                            currentBathDataIndex = batchIndex + 1;
                        }
                        break;
                    }
                    else
                    {
                        string resultPath = simulator.OutputResult();
                        simulator.WeightSave(resultPath + "Status.WDATA");

                        currentLearningSetupIndex = 0;
                        currentEpoch = 0;
                        totalEpoch = 0;
                    }
                }
                if (learningStatus == LearningStatus.Pausing)
                {
                    learningStatus = LearningStatus.Paused;
                    break;
                }
            }
            if (learningStatus == LearningStatus.Training || learningStatus == LearningStatus.Test) learningStatus = LearningStatus.End;
        }