Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ZyanProxy"/> class.
        /// </summary>
        /// <param name="uniqueName">Unique component name.</param>
        /// <param name="type">Component interface type.</param>
        /// <param name="connection"><see cref="ZyanConnection"/> instance.</param>
        /// <param name="implicitTransactionTransfer">Specifies whether transactions should be passed implicitly.</param>
        /// <param name="keepSynchronizationContext">Specifies whether callbacks and event handlers should use the original synchronization context.</param>
        /// <param name="sessionID">Session ID.</param>
        /// <param name="componentHostName">Name of the remote component host.</param>
        /// <param name="autoLoginOnExpiredSession">Specifies whether Zyan should login automatically with cached credentials after the session is expired.</param>
        /// <param name="activationType">Component activation type</param>
        public ZyanProxy(string uniqueName, Type type, ZyanConnection connection, bool implicitTransactionTransfer, bool keepSynchronizationContext, Guid sessionID, string componentHostName, bool autoLoginOnExpiredSession, ActivationType activationType)
            : base(type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            if (connection == null)
                throw new ArgumentNullException("connection");

            if (string.IsNullOrEmpty(uniqueName))
                _uniqueName = type.FullName;
            else
                _uniqueName = uniqueName;

            _sessionID = sessionID;
            _connection = connection;
            _componentHostName = componentHostName;
            _interfaceType = type;
            _activationType = activationType;
            _remoteDispatcher = _connection.RemoteDispatcher;
            _implicitTransactionTransfer = implicitTransactionTransfer;
            _autoLoginOnExpiredSession = autoLoginOnExpiredSession;
            _delegateCorrelationSet = new List<DelegateCorrelationInfo>();

            // capture synchronization context for callback execution
            if (keepSynchronizationContext)
            {
                _synchronizationContext = SynchronizationContext.Current;
            }
        }
 public EffectActivator(string target, MemoryAddress address, ActivationType activation, DeactivationType deactivation)
 {
     Target = address.ConvertToRightDataType(target);
     Address = address;
     ActivationType = activation;
     DeactivationType = deactivation;
 }
Beispiel #3
0
 /// <summary>
 /// Konstruktor.
 /// </summary>
 /// <param name="interfaceType">Schnittstellentyp der Komponente</param>
 /// <param name="implementationType">Implementierungstyp der Komponente</param>                
 /// <param name="activationType">Aktivierungsart</param>
 public ComponentRegistration(Type interfaceType, Type implementationType, ActivationType activationType)
     : this()
 {
     // Werte übernehmen
     this.InterfaceType = interfaceType;
     this.ImplementationType = implementationType;
     this.ActivationType = activationType;
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new instance of the ComponentRegistration class.
 /// </summary>
 /// <param name="interfaceType">Interface type of the component</param>
 /// <param name="implementationType">Implementation type of the component</param>
 /// <param name="activationType">Activation type (Singleton/SingleCall)</param>
 public ComponentRegistration(Type interfaceType, Type implementationType, ActivationType activationType)
     : this()
 {
     this.InterfaceType = interfaceType;
     this.ImplementationType = implementationType;
     this.ActivationType = activationType;
     this.UniqueName = interfaceType.FullName;
     this.EventStub = new EventStub(InterfaceType);
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of the ComponentRegistration class.
 /// </summary>
 /// <param name="interfaceType">Interface type of the component</param>
 /// <param name="implementationType">Implementation type of the component</param>
 /// <param name="activationType">Activation type (Singleton/SingleCall)</param>
 /// <param name="cleanUpHandler">Delegate of clean up method</param>
 public ComponentRegistration(Type interfaceType, Type implementationType, ActivationType activationType, Action<object> cleanUpHandler)
     : this()
 {
     this.InterfaceType = interfaceType;
     this.ImplementationType = implementationType;
     this.ActivationType = activationType;
     this.UniqueName = interfaceType.FullName;
     this.CleanUpHandler = cleanUpHandler;
     this.EventStub = new EventStub(InterfaceType);
 }
Beispiel #6
0
        public void LoadTrainingData(string trainingDataPath, ProblemType problem, ActivationType activation)
        {
            TrainingDataPath = trainingDataPath;

            var csvReader = new ReadCSV(trainingDataPath, true, CSVFormat.DecimalPoint);

            var values = new List<double[]>();
            var answers = new List<double[]>();

            while (csvReader.Next())
            {
                if (ProblemType.Classification == problem)
                {
                    values.Add(new []{csvReader.GetDouble(0), csvReader.GetDouble(1)});
                    answers.Add(new []{csvReader.GetDouble(2)});
                }
                else
                {
                    values.Add(new[] { csvReader.GetDouble(0)});
                    answers.Add(new[] { csvReader.GetDouble(1) });

                    _originalRegressionValues.Add(values.Last()[0]);
                    _originalRegressionAnswers.Add(answers.Last()[0]);
                }
            }

            csvReader.Close();

            if (problem == ProblemType.Classification)
            {
                answers = SpreadClassificationAnswers(answers, activation);
                FirstLayerSize = 2;
            }
            else
                LastLayerSize = FirstLayerSize = 1;

            AnalizeValues(problem, values);
            Normalize(values, _valuesMins, _valuesMaxes, activation);

            if (problem == ProblemType.Regression)
            {
                AnalizeAnswers(answers);
                Normalize(answers, _answersMins, _answersMaxes, activation);
            }

            values.StableShuffle();
            answers.StableShuffle();
            ListExtensions.ResetStableShuffle();

            var trainingSetSize = (int)(values.Count * 0.85);

            TrainingDataSet = new BasicMLDataSet(values.Take(trainingSetSize).ToArray(), answers.Take(trainingSetSize).ToArray());
            ValidationDataSet = new BasicMLDataSet(values.Skip(trainingSetSize).ToArray(), answers.Skip(trainingSetSize).ToArray());
        }
		void Start()
		{
			ray             = GetComponentInChildren<PointerRay>();
			transportAction = InputHandler.Find(actionName);

			if (ray == null)
			{
				// activate and release doesn't make much sense without the ray
				activationType  = ActivationType.OnTrigger;
			}
			teleporter      = GameObject.FindObjectOfType<Teleporter>();
		}
Beispiel #8
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="type">Schnittstelle der entfernten Komponente</param>
        /// <param name="connection">Verbindungsobjekt</param>
        /// <param name="implicitTransactionTransfer">Implizite Transaktionsübertragung</param>
        /// <param name="sessionID">Sitzungsschlüssel</param>
        /// <param name="componentHostName">Name des entfernten Komponentenhosts</param>
        /// <param name="autoLoginOnExpiredSession">Gibt an, ob sich der Proxy automatisch neu anmelden soll, wenn die Sitzung abgelaufen ist</param>
        /// <param name="autoLogoninCredentials">Optional! Anmeldeinformationen, die nur benötigt werden, wenn autoLoginOnExpiredSession auf Wahr eingestellt ist</param>              
        /// <param name="activationType">Aktivierungsart</param>
        public ZyanProxy(Type type, ZyanConnection connection, bool implicitTransactionTransfer, Guid sessionID, string componentHostName, bool autoLoginOnExpiredSession, Hashtable autoLogoninCredentials, ActivationType activationType)
            : base(type)
        {
            // Wenn kein Typ angegeben wurde ...
            if (type.Equals(null))
                // Ausnahme werfen
                throw new ArgumentNullException("type");

            // Wenn kein Verbindungsobjekt angegeben wurde ...
            if (connection == null)
                // Ausnahme werfen
                throw new ArgumentNullException("connection");

            // Sitzungsschlüssel übernehmen
            _sessionID = sessionID;

            // Verbindungsobjekt übernehmen
            _connection = connection;

            // Name des Komponentenhosts übernehmen
            _componentHostName = componentHostName;

            // Schnittstellentyp übernehmen
            _interfaceType = type;

            // Aktivierungsart übernehmen
            _activationType = activationType;

            // Aufrufer von Verbindung übernehmen
            _remoteInvoker = _connection.RemoteComponentFactory;

            // Schalter für implizite Transaktionsübertragung übernehmen
            _implicitTransactionTransfer = implicitTransactionTransfer;

            // Schalter für automatische Anmeldung bei abgelaufender Sitzung übernehmen
            _autoLoginOnExpiredSession = autoLoginOnExpiredSession;

            // Wenn automatische Anmeldung aktiv ist ...
            if (_autoLoginOnExpiredSession)
                // Anmeldeinformationen speichern
                _autoLoginCredentials = autoLogoninCredentials;

            // Sammlung für Korrelationssatz erzeugen
            _delegateCorrelationSet = new List<DelegateCorrelationInfo>();
        }
Beispiel #9
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                if (activationType == ActivationType.AddedToHierarchy)
                {
                    _backButton = BeatSaberUI.CreateBackButton(rectTransform);
                    _backButton.onClick.AddListener(delegate() { if (!_isInTransition && !_parentViewController.GetPrivateField <bool>("_isInTransition"))
                                                                 {
                                                                     didFinishEvent?.Invoke();
                                                                 }
                                                    });

                    _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                    _loadingIndicator.SetActive(false);
                }
            }
        }
Beispiel #10
0
        public static ActivationPair Get(ActivationType type)
        {
            switch (type)
            {
            case ActivationType.Identity:
                return(new ActivationPair(Vectorize(Identity), Vectorize(Identity)));

            case ActivationType.ReLU:
                return(new ActivationPair(Vectorize(ReLU), Vectorize(dReLU)));

            case ActivationType.Logistic:
                return(new ActivationPair(Vectorize(Logistic), Vectorize(dLogistic)));

            case ActivationType.Softmax:
                return(new ActivationPair(Softmax, dSoftmax));
            }
            throw new Exception("Unknown activation type " + type);
        }
Beispiel #11
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);

            if (firstActivation)
            {
                rectTransform.anchorMin = new Vector3(0.5f, 0, 0);
                rectTransform.anchorMax = new Vector3(0.5f, 1, 0);
                rectTransform.sizeDelta = new Vector3(70, 0, 0);

                if (image.gameObject.GetComponent <AspectRatioFitter>() == null)
                {
                    var element = image.gameObject.AddComponent <AspectRatioFitter>();
                    element.aspectRatio = 1f;
                    element.aspectMode  = AspectRatioFitter.AspectMode.HeightControlsWidth;
                }
            }
        }
Beispiel #12
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            base.DidActivate(firstActivation, activationType);

            if (firstActivation)
            {
                try
                {
                    var assembly = System.Reflection.Assembly.GetExecutingAssembly();
                    var content  = BeatSaberMarkupLanguage.Utilities.GetResourceContent(assembly, ResourceName);
                    BSMLParser.instance.Parse(content, gameObject, this);
                }
                catch (Exception ex)
                {
                    Logger.IPALogger.Critical($"BSML Parse Error\n{ex.ToString()}");
                }
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (activationType != ActivationType.AddedToHierarchy)
            {
                return;
            }

            _ui = TwitchIntegrationUi.Instance;

            if (_backButtonObject == null)
            {
                _backButtonObject = _ui.CreateBackButton(rectTransform);
            }

            _backButtonObject.gameObject.SetActive(true);

            _backButtonObject.onClick.AddListener(DismissButtonWasPressed);
        }
 protected override void DidActivate(bool firstActivation, ActivationType activationType)
 {
     if (firstActivation)
     {
         title = "BeFit Users";
         ui    = BeFitUI._instance;
     }
     if (_beFitListViewController == null)
     {
         _beFitListViewController = BeatSaberUI.CreateViewController <BeFitListViewController>();
         _beFitListViewController.beFitListBackWasPressed += Dismiss;
         _beFitListViewController.beFitListNewUserPressed += Dismiss;
     }
     if (activationType == FlowCoordinator.ActivationType.AddedToHierarchy)
     {
         ProvideInitialViewControllers(_beFitListViewController, null, null);
     }
 }
Beispiel #15
0
        void Start()
        {
            ray             = GetComponentInChildren <PointerRay>();
            transportAction = InputHandler.Find(actionName);

            if (ray == null)
            {
                // activate and release doesn't make much sense without the ray
                activationType  = ActivationType.OnTrigger;
                rayAlwaysActive = false;
            }
            else
            {
                rayAlwaysActive = ray.rayEnabled;
            }

            teleporter = GameObject.FindObjectOfType <Teleporter>();
        }
Beispiel #16
0
        public Model(int inputsCount, ActivationType inputActivationType, int outputsCount, ActivationType outputActivationType, CostType costType)
        {
            var inputLayer = new AffineLayer(inputsCount, inputActivationType);

            _layers.AddFirst(inputLayer);
            inputLayer.SetListNode(_layers.First);

            var outputLayer = new AffineLayer(outputsCount, outputActivationType);

            _layers.AddLast(outputLayer);
            outputLayer.SetListNode(_layers.Last);

            LossLayer = new LossLayer(costType, outputsCount);
            _layers.AddLast(LossLayer);
            LossLayer.SetListNode(_layers.Last);

            UpdateLayersIds();
        }
Beispiel #17
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            _mainScreen = GameObject.Find("MainScreen");

            showBackButton = true;

            if (firstActivation)
            {
                title            = "Custom Avatars";
                _mainScreenScale = _mainScreen.transform.localScale;
            }

            if (activationType == ActivationType.AddedToHierarchy)
            {
                ProvideInitialViewControllers(_mirrorViewController, _settingsViewController, _avatarListViewController);
                _mainScreen.transform.localScale = Vector3.zero;
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                title = "Platform Select";

                ui = PlatformUI._instance;
            }
            if (_platformListViewController == null)
            {
                _platformListViewController = BeatSaberUI.CreateViewController <PlatformListViewController>();
                _platformListViewController.platformListBackWasPressed += Dismiss;
            }
            if (activationType == FlowCoordinator.ActivationType.AddedToHierarchy)
            {
                ProvideInitialViewControllers(_platformListViewController, null, null);
            }
        }
Beispiel #19
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (activationType == ActivationType.AddedToHierarchy)
            {
                title = "Media Panel";

                if (mainFlowCoordinator == null)
                {
                    mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();
                }

                mainModNavigationController = BeatSaberUI.CreateViewController <GeneralNavigationController>();
                mainModNavigationController.didFinishEvent += (_) => mainFlowCoordinator.InvokeMethod("DismissFlowCoordinator", this, null, false);

                ProvideInitialViewControllers(mainModNavigationController, null, null);
                OpenFileList();
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                var referenceViewController             = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First();
                StandardLevelDetailView reference       = referenceViewController.GetPrivateField <StandardLevelDetailView>("_standardLevelDetailView");
                RectTransform           referenceParent = reference.transform.parent as RectTransform;

                this.rectTransform.anchorMin        = referenceParent.anchorMin;
                this.rectTransform.anchorMax        = referenceParent.anchorMax;
                this.rectTransform.anchoredPosition = Vector2.zero;
                this.rectTransform.sizeDelta        = new Vector2(80f, 0f);

                _standardLevelDetailView = Instantiate(reference, this.transform, false);
                _standardLevelDetailView.gameObject.SetActive(true);
                _standardLevelDetailView.name = "SearchResultLevelDetail";

                _levelParamsPanel = _standardLevelDetailView.GetPrivateField <LevelParamsPanel>("_levelParamsPanel");
                _songNameText     = _standardLevelDetailView.GetPrivateField <TextMeshProUGUI>("_songNameText");

                _checkmarkSprite = UIUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.checkmark.png");
                _crossSprite     = UIUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.cross.png");
                _blankSprite     = Sprite.Create(Texture2D.blackTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero);

                RemoveCustomUIElements(this.rectTransform);
                RemoveSongRequirementsButton();
                ModifyPanelElements();
                ModifyTextElements();
                ModifySelectionElements();
            }
            else
            {
                // stats panel gets disabled when in party mode, so re-enable it here just in case
                RectTransform statsPanel = _standardLevelDetailView.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "Stats");
                statsPanel.gameObject.SetActive(true);
                _compactKeyboardButton.gameObject.SetActive(PluginConfig.CompactSearchMode);

                // strings get reset, so they have to be reapplied
                foreach (var str in _difficultyStrings)
                {
                    _difficultyElements[str].Item1.text = str;
                }
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            title = "Video - " + selectedLevel.songName;

            if (_videoDetailViewController == null)
            {
                _videoDetailViewController = BeatSaberUI.CreateViewController <VideoDetailViewController>();
                _videoDetailViewController.Init();
                _videoDetailViewController.backButtonPressed           += DetailViewBackPressed;
                _videoDetailViewController.addOffsetPressed            += DetailViewAddOffsetPressed;
                _videoDetailViewController.subOffsetPressed            += DetailViewSubOffsetPressed;
                _videoDetailViewController.previewButtonPressed        += DetailViewPreviewPressed;
                _videoDetailViewController.loopButtonPressed           += DetailViewLoopPressed;
                _videoDetailViewController.listButtonPressed           += DetailViewSearchPressed;
                _videoDetailViewController.downloadDeleteButtonPressed += DetailViewDownloadDeletePressed;
            }
            if (_videoListViewController == null)
            {
                _videoListViewController = BeatSaberUI.CreateViewController <VideoListViewController>();
                _videoListViewController.backButtonPressed     += ListViewBackPressed;
                _videoListViewController.downloadButtonPressed += ListViewDownloadPressed;
                _videoListViewController.searchButtonPressed   += ListViewSearchPressed;
            }
            if (_simpleDialog == null)
            {
                _simpleDialog = Resources.FindObjectsOfTypeAll <SimpleDialogPromptViewController>().First();
                _simpleDialog = Instantiate(_simpleDialog.gameObject, _simpleDialog.transform.parent).GetComponent <SimpleDialogPromptViewController>();
            }
            if (activationType == FlowCoordinator.ActivationType.AddedToHierarchy)
            {
                Console.WriteLine("selectedLevelVideo = " + selectedLevelVideo != null);
                Console.WriteLine("_videoDetailViewController = " + _videoDetailViewController != null);
                Console.WriteLine("_videoListViewController = " + _videoListViewController != null);
                Console.WriteLine("_simpleDialog = " + _simpleDialog != null);
                _videoDetailViewController.SetContent(selectedLevelVideo);
                previewPlaying = false;
                _videoDetailViewController.SetPreviewState(previewPlaying);
                if (selectedLevelVideo != null)
                {
                    ScreenManager.Instance.ShowScreen();
                }
                ProvideInitialViewControllers(_videoDetailViewController, null, null);
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (firstActivation)
            {
                RectTransform KeyboardContainer = new GameObject("KeyboardContainer", typeof(RectTransform)).transform as RectTransform;
                KeyboardContainer.SetParent(rectTransform, false);
                KeyboardContainer.sizeDelta = new Vector2(60f, 40f);

                var mykeyboard = new KEYBOARD(KeyboardContainer, "");

#if UNRELEASED
                RequestBot.AddKeyboard(mykeyboard, "emotes.kbd", 0.4f);
#endif
                mykeyboard.AddKeys(KEYBOARD.QWERTY); // You can replace this with DVORAK if you like
                mykeyboard.DefaultActions();

#if UNRELEASED
                const string SEARCH = @"

[CLEAR SEARCH]/0 /2 [NEWEST]/0 /2 [UNFILTERED]/30 /2 [PP]/0'!addsongs/top/pp pp%CR%' /2 [SEARCH]/0";
#else
                const string SEARCH = @"

[CLEAR SEARCH]/0 /2 [NEWEST]/0 /2 [UNFILTERED]/30 /2 [SEARCH]/0";
#endif


                mykeyboard.SetButtonType("OkButton"); // Adding this alters button positions??! Why?
                mykeyboard.AddKeys(SEARCH, 0.75f);

                mykeyboard.SetAction("CLEAR SEARCH", RequestBot.ClearSearch);
                mykeyboard.SetAction("UNFILTERED", RequestBot.UnfilteredSearch);
                mykeyboard.SetAction("SEARCH", RequestBot.MSD);
                mykeyboard.SetAction("NEWEST", RequestBot.Newest);


#if UNRELEASED
                RequestBot.AddKeyboard(mykeyboard, "decks.kbd", 0.4f);
#endif

                // The UI for this might need a bit of work.
                RequestBot.AddKeyboard(mykeyboard, "RightPanel.kbd");
            }
        }
Beispiel #23
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title = "More Songs";

                _moreSongsListViewController = BeatSaberUI.CreateViewController <MoreSongsListViewController>();
                _moreSongsListViewController.pageDownPressed += _moreSongsListViewController_pageDownPressed;
                _moreSongsListViewController.pageUpPressed   += _moreSongsListViewController_pageUpPressed;


                _moreSongsListViewController.sortByTop += () => { ResetDetailView(); currentSortMode = "hot"; currentPage = 0; StartCoroutine(GetPage(currentPage, currentSortMode)); currentSearchRequest = ""; };
                _moreSongsListViewController.sortByNew += () => { ResetDetailView(); currentSortMode = "latest"; currentPage = 0; StartCoroutine(GetPage(currentPage, currentSortMode)); currentSearchRequest = ""; };

                _moreSongsListViewController.sortByNewlyRanked += () => { ResetDetailView(); currentScoreSaberSortMode = 1; currentPage = 0; StartCoroutine(GetPageScoreSaber(currentPage, currentScoreSaberSortMode)); };
                _moreSongsListViewController.sortByTrending    += () => { ResetDetailView(); currentScoreSaberSortMode = 0; currentPage = 0; StartCoroutine(GetPageScoreSaber(currentPage, currentScoreSaberSortMode)); };
                _moreSongsListViewController.sortByDifficulty  += () => { ResetDetailView(); currentScoreSaberSortMode = 3; currentPage = 0; StartCoroutine(GetPageScoreSaber(currentPage, currentScoreSaberSortMode)); };

                _moreSongsListViewController.searchButtonPressed += _moreSongsListViewController_searchButtonPressed;
                _moreSongsListViewController.didSelectRow        += _moreSongsListViewController_didSelectRow;

                _downloadQueueViewController = BeatSaberUI.CreateViewController <DownloadQueueViewController>();

                _descriptionViewController              = BeatSaberUI.CreateViewController <SongDescriptionViewController>();
                _descriptionViewController.linkClicked += LinkClicked;

                _simpleDialog = CustomUI.Utilities.ReflectionUtil.GetPrivateField <SimpleDialogPromptViewController>(Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First(), "_simpleDialogPromptViewController");
                _simpleDialog = Instantiate(_simpleDialog.gameObject, _simpleDialog.transform.parent).GetComponent <SimpleDialogPromptViewController>();
            }

            SongDownloader.Instance.songDownloaded -= SongDownloader_songDownloaded;
            SongDownloader.Instance.songDownloaded += SongDownloader_songDownloaded;

            SetViewControllersToNavigationConctroller(_moreSongsNavigationController, new VRUIViewController[]
            {
                _moreSongsListViewController
            });
            ProvideInitialViewControllers(_moreSongsNavigationController, _downloadQueueViewController, _descriptionViewController);

            currentPage          = 0;
            currentSortMode      = "top";
            currentSearchRequest = "";
            StartCoroutine(GetPageScoreSaber(0, 0));
        }
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);

            if (firstActivation && type == ActivationType.AddedToHierarchy)
            {
                _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform, delegate() { backButtonPressed?.Invoke(); });

                RectTransform container = new GameObject("VideoListContainer", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.sizeDelta = new Vector2(105f, 0f);

                _searchButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -20), new Vector2(30, 8), () =>
                {
                    searchButtonPressed?.Invoke();
                }, "Refine");

                _downloadButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -30), new Vector2(30, 8), () =>
                {
                    downloadButtonPressed?.Invoke(resultsList[_lastSelectedRow]);
                }, "Download");
//                _downloadButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0);

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                _customListTableView.didSelectCellWithIdxEvent -= DidSelectRowEvent;
                _customListTableView.didSelectCellWithIdxEvent += _songsTableView_DidSelectRowEvent;

                (_customListTableView.transform.parent as RectTransform).sizeDelta = new Vector2(105, 0);
                (_customListTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                (_customListTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                (_customListTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_customListTableView.transform as RectTransform).anchoredPosition = new Vector3(-10f, 0f);
            }
            else
            {
                _customListTableView.ReloadData();
            }
            _downloadButton.interactable = false;
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            try
            {
                if (firstActivation && activationType == ActivationType.AddedToHierarchy)
                {
                    title = "Playlists";

                    if (_playlistsReader == null)
                    {
                        _playlistsReader = new PlaylistsReader();
                        _playlistsReader.UpdatePlaylists();
                        Logger.Debug("Reader found {0} playlists!", _playlistsReader.Playlists.Count);

                        this.MatchSongsForAllPlaylists(true);
                    }

                    _playlistsNavigationController.didFinishEvent += _playlistsNavigationController_didFinishEvent;

                    _playlistListViewController = BeatSaberUI.CreateViewController <PlaylistListViewController>();
                    _playlistListViewController.didSelectRow += _playlistListViewController_didSelectRow;

                    _playlistDetailViewController.downloadButtonPressed += _playlistDetailViewController_downloadButtonPressed;
                    _playlistDetailViewController.selectButtonPressed   += _playlistDetailViewController_selectButtonPressed;

                    _downloadQueueViewController = BeatSaberUI.CreateViewController <DownloadQueueViewController>();

                    SetViewControllersToNavigationConctroller(_playlistsNavigationController, new VRUIViewController[]
                    {
                        _playlistListViewController
                    });

                    ProvideInitialViewControllers(_playlistsNavigationController, _downloadQueueViewController, null);
                }
                _downloadingPlaylist = false;
                _playlistListViewController.SetContent(_playlistsReader.Playlists);

                _downloadQueueViewController.allSongsDownloaded += _downloadQueueViewController_allSongsDownloaded;
            }
            catch (Exception e)
            {
                Logger.Exception("Error activating playlist flow coordinator: ", e);
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                channelSelectionNavController = BeatSaberUI.CreateViewController <MultiplayerNavigationController>();
                channelSelectionNavController.didFinishEvent += () => { PluginUI.instance.modeSelectionFlowCoordinator.InvokeMethod("DismissFlowCoordinator", this, null, false); };

                channelSelectionViewController = BeatSaberUI.CreateViewController <ChannelSelectionViewController>();
                channelSelectionViewController.nextPressedEvent += () =>
                {
                    currentChannel++;
                    if (currentChannel >= _channelInfos.Count)
                    {
                        currentChannel = 0;
                    }
                    channelSelectionViewController.SetContent(_channelInfos[currentChannel]);
                };
                channelSelectionViewController.prevPressedEvent += () =>
                {
                    currentChannel--;
                    if (currentChannel < 0)
                    {
                        currentChannel = _channelInfos.Count - 1;
                    }
                    channelSelectionViewController.SetContent(_channelInfos[currentChannel]);
                };
                channelSelectionViewController.joinPressedEvent += (channel) =>
                {
                    if (!mainScreenViewControllers.Any(x => x.GetPrivateField <bool>("_isInTransition")))
                    {
                        PresentFlowCoordinator(PluginUI.instance.radioFlowCoordinator, null, false, false);
                        PluginUI.instance.radioFlowCoordinator.JoinChannel(channel.ip, channel.port, channel.channelId);
                        PluginUI.instance.radioFlowCoordinator.didFinishEvent -= DismissRadio;
                        PluginUI.instance.radioFlowCoordinator.didFinishEvent += DismissRadio;
                    }
                };
            }


            SetViewControllerToNavigationConctroller(channelSelectionNavController, channelSelectionViewController);
            ProvideInitialViewControllers(channelSelectionNavController, null, null);

            StartCoroutine(GetChannelsList());
        }
Beispiel #27
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                title = "Mod Settings";
                navigationController = BeatSaberUI.CreateViewController <NavigationController>();
                BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "BeatSaberMarkupLanguage.Views.settings-buttons.bsml"), navigationController.gameObject, this);

                settingsMenuListViewController              = BeatSaberUI.CreateViewController <SettingsMenuListViewController>();
                settingsMenuListViewController.clickedMenu += OpenMenu;
                SetViewControllerToNavigationController(navigationController, settingsMenuListViewController);
                ProvideInitialViewControllers(navigationController);

                foreach (CustomCellInfo cellInfo in BSMLSettings.instance.settingsMenus)
                {
                    (cellInfo as SettingsMenu).parserParams.AddEvent("back", Back);
                }
            }
        }
Beispiel #28
0
 public Conv3D(uint filters, Tuple <uint, uint, uint> kernalSize, uint strides = 1, PaddingType padding   = PaddingType.Same, Tuple <uint, uint, uint> dialationRate = null,
               ActivationType activation       = ActivationType.Linear, BaseInitializer kernalInitializer = null, BaseRegularizer kernalRegularizer = null,
               BaseConstraint kernalConstraint = null, bool useBias = true, BaseInitializer biasInitializer = null, BaseRegularizer biasRegularizer = null, BaseConstraint biasConstraint = null)
     : base("conv3d")
 {
     Filters           = filters;
     KernalSize        = kernalSize;
     Strides           = strides;
     Padding           = padding;
     DialationRate     = dialationRate ?? Tuple.Create <uint, uint, uint>(1, 1, 1);
     Activation        = activation;
     UseBias           = useBias;
     KernalInitializer = kernalInitializer ?? new GlorotUniform();
     BiasInitializer   = biasInitializer ?? new Zeros();
     KernalConstraint  = kernalConstraint;
     BiasConstraint    = biasConstraint;
     KernalRegularizer = kernalRegularizer;
     BiasRegularizer   = biasRegularizer;
 }
Beispiel #29
0
 protected override void DidActivate(bool firstActivation, ActivationType activationType)
 {
     try
     {
         if (firstActivation)
         {
             title          = "Hit Sounds";
             showBackButton = true;
             ProvideInitialViewControllers(_soundListView);
         }
         if (activationType == ActivationType.AddedToHierarchy)
         {
         }
     }
     catch (Exception ex)
     {
         Utilities.Logging.Log.Error(ex);
     }
 }
Beispiel #30
0
        // Активация значения x функцией типа type
        public static double Activate(ActivationType type, double x)
        {
            switch (type)
            {
            case ActivationType.sigmoid:
                return(Sigmoid(x));

            case ActivationType.tanh:
                return(Tangent(x));

            case ActivationType.relu:
                return(ReLU(x));

            case ActivationType.nochange:
                return(NoChange(x));
            }

            throw new Exception("ActivationFunctions: uncased type!");
        }
Beispiel #31
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (firstActivation)
            {
                _songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));

                RectTransform container = new GameObject("CustomListContainer", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.sizeDelta = new Vector2(60f, 0f);

                _customListTableView = new GameObject("CustomListTableView").AddComponent <TableView>();
                _customListTableView.gameObject.AddComponent <RectMask2D>();
                _customListTableView.transform.SetParent(container, false);

                (_customListTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0f);
                (_customListTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 1f);
                (_customListTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_customListTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f);

                _customListTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]);
                _customListTableView.SetPrivateField("_isInitialized", false);
                _customListTableView.dataSource = this;

                _customListTableView.didSelectRowEvent += _customListTableView_didSelectRowEvent;

                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), container, false);
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 30f);//-14
                _pageUpButton.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    _customListTableView.PageScrollUp();
                });

                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), container, false);
                (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -30f);//8
                _pageDownButton.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    _customListTableView.PageScrollDown();
                });
            }
            base.DidActivate(firstActivation, type);
        }
Beispiel #32
0
        public override void DoActivation(Volume <float> volume, ActivationType type)
        {
            switch (type)
            {
            case ActivationType.Sigmoid:
                this.Storage.Map(x => (float)(1.0 / (1.0 + Math.Exp(-x))), volume.Storage);
                return;

            case ActivationType.Relu:
                throw new NotImplementedException();

            case ActivationType.Tanh:
                this.Storage.Map(x => (float)Math.Tanh(x), volume.Storage);
                return;

            case ActivationType.ClippedRelu:
                throw new NotImplementedException();
            }
        }
        public static cudnnActivationMode ToCudnn(this ActivationType type)
        {
            switch (type)
            {
            case ActivationType.Sigmoid:
                return(cudnnActivationMode.Sigmoid);

            case ActivationType.Relu:
                return(cudnnActivationMode.Relu);

            case ActivationType.Tanh:
                return(cudnnActivationMode.Tanh);

            case ActivationType.ClippedRelu:
                return(cudnnActivationMode.ClippedRelu);
            }

            throw new NotImplementedException();
        }
        public void ActivateContextButtons(ActivationType activationType)
        {
            if (ContextMenuItems == null)
            {
                LoadContextMenu();
            }

            AreContextButtonsActive = true;

            if (activationType == ActivationType.Selection)
            {
                IsSelected = true;
                EnableContextMenuAcceleratorKeys();
            }
            else if (activationType == ActivationType.Hover)
            {
                IsHovered = true;
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);
            if (firstActivation)
            {
                rectTransform.anchorMin = new Vector3(0.5f, 0, 0);
                rectTransform.anchorMax = new Vector3(0.5f, 1, 0);
                rectTransform.sizeDelta = new Vector3(70, 0, 0);
            }

            if (BSMOTDManager.instance.ListDirty)
            {
                List <Post> sorted = BSMOTDManager.instance.posts.OrderByDescending(q => q.uploaded).ToList();

                customListTableData.data.Clear();
                customListTableData.data.AddRange(sorted);
                customListTableData.tableView.ReloadData();
            }
        }
        // получение производной функции активации с типом type
        public static ActivationFunction GetDerivative(ActivationType type)
        {
            switch (type)
            {
            case ActivationType.sigmoid:
                return(SigmoidDerivative);

            case ActivationType.tanh:
                return(TangentDerivative);

            case ActivationType.relu:
                return(ReLUDerivative);

            case ActivationType.nochange:
                return(NoChangeDerivative);
            }

            throw new Exception("ActivationFunctions: uncased type!");
        }
Beispiel #37
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            try
            {
                if (firstActivation)
                {
                    Instance     = this;
                    cellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First((LevelListTableCell x) => x.name == "LevelListTableCell");
                    base.DidActivate(firstActivation, type);

                    foreach (var kvp in AdvancedCounterSettings.counterUIItems)
                    {
                        counterInfos.Add(CreateFromModel(kvp.Key));
                    }
                    FileIniDataParser parser = new FileIniDataParser();
                    IniData           data   = parser.ReadFile(Path.Combine(BeatSaber.UserDataPath, "CountersPlus.ini"));
                    foreach (SectionData section in data.Sections)
                    {
                        if (section.Keys.Any((KeyData x) => x.KeyName == "SectionName") &&
                            PluginUtility.IsPluginPresent(section.Keys["ModCreator"]))
                        {
                            CustomConfigModel potential = new CustomConfigModel(section.SectionName);
                            potential = ConfigLoader.DeserializeFromConfig(potential, section.SectionName) as CustomConfigModel;

                            counterInfos.Add(new SettingsInfo()
                            {
                                Name        = potential.DisplayName,
                                Description = $"A custom counter added by {potential.ModCreator}!",
                                Model       = potential,
                                IsCustom    = true,
                            });
                        }
                    }
                    _customListTableView.didSelectCellWithIdxEvent += OnCellSelect;
                    _customListTableView.ReloadData();
                    _customListTableView.SelectCellWithIdx(0, false);
                }
            }
            catch (Exception e) {
                Plugin.Log(e.Message + e.StackTrace, Plugin.LogInfo.Fatal, "Check dependencies. If issue persists, re-install Counters+. If issue still persists, create an issue on the Counters+ GitHub.");
            }
        }
Beispiel #38
0
        public override void DoActivation(Volume <double> volume, ActivationType type)
        {
            switch (type)
            {
            case ActivationType.Sigmoid:
                this.Storage.Map(x => 1.0 / (1.0 + Math.Exp(-x)), volume.Storage);
                return;

            case ActivationType.Relu:
                this.DoRelu(volume);
                break;

            case ActivationType.Tanh:
                this.Storage.Map(Math.Tanh, volume.Storage);
                break;

            case ActivationType.ClippedRelu:
                throw new NotImplementedException();
            }
        }
        /// <summary>
        /// Create an activation function object
        /// </summary>
        /// <param name="type"> The type of the activation function </param>
        /// <returns> An instant of an activation function object </returns>
        public static AActivationFunction CreateActivationFnCLass( ActivationType type )
        {
            AActivationFunction _activationFunction = null;

            Assembly assembly = Assembly.GetCallingAssembly();
            Type[] types = assembly.GetTypes();

            for( int i = 0 ; i < types.Length ; i++ )
            {
                if (types[i].IsSubclassOf(typeof(AActivationFunction)) && types[i].Name == type.ToString() )
                {
                    _activationFunction = (AActivationFunction)System.Activator.CreateInstance(types[i]);
                    break;
                }
            }

            if ( _activationFunction == null)
                throw new ArgumentNullException("Activation Function ( Type not found )");

            return _activationFunction;
        }
Beispiel #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ZyanProxy"/> class.
        /// </summary>
        /// <param name="uniqueName">Unique component name.</param>
        /// <param name="type">Component interface type.</param>
        /// <param name="connection"><see cref="ZyanConnection"/> instance.</param>
        /// <param name="implicitTransactionTransfer">Specifies whether transactions should be passed implicitly.</param>
        /// <param name="sessionID">Session ID.</param>
        /// <param name="componentHostName">Name of the remote component host.</param>
        /// <param name="autoLoginOnExpiredSession">Specifies whether Zyan should login automatically with cached credentials after the session is expired.</param>
        /// <param name="activationType">Component activation type</param>
        public ZyanProxy(string uniqueName, Type type, ZyanConnection connection, bool implicitTransactionTransfer, Guid sessionID, string componentHostName, bool autoLoginOnExpiredSession, ActivationType activationType)
            : base(type)
        {
            if (type.Equals(null))
                throw new ArgumentNullException("type");

            if (connection == null)
                throw new ArgumentNullException("connection");

            if (string.IsNullOrEmpty(uniqueName))
                _uniqueName = type.FullName;
            else
                _uniqueName = uniqueName;

            _sessionID = sessionID;
            _connection = connection;
            _componentHostName = componentHostName;
            _interfaceType = type;
            _activationType = activationType;
            _implicitTransactionTransfer = implicitTransactionTransfer;
            _autoLoginOnExpiredSession = autoLoginOnExpiredSession;
            _delegateCorrelationSet = new List<DelegateCorrelationInfo>();
        }
Beispiel #41
0
        private double DenormalizeAnswer(double answer, ActivationType activation)
        {
            var min = ActivationType.Bipolar == activation ? -1.0 : 0.0;
            var max = 1.0;
            var norm = max - min;
            var size = _answersMaxes[0] - _answersMins[0];

            return ((answer - min) * size / norm) + _answersMins[0];
        }
    /**
     * Generate Activation Tiles based on the range and
     * center given
     *
     * Arguments
     * - double range - The range
     * - int initialX - The X coordinate of the centre
     * - int initialY - The Y coordinate of the centre
     * - RangeType rangeType - The type of range
     * - ActivationType activationType - The activation type
     */
    void generateActivationTiles(double range, int initialX, int initialZ, RangeType rangeType, 
			ActivationType activationType)
    {
        Material tileMaterial; // The material to set

        // First, determine the tile colour
        switch (activationType) {
        case ActivationType.OFFENSIVE:
            tileMaterial = OffensiveTileMaterial;
            break;
        case ActivationType.DEFENSIVE:
            tileMaterial = DefensiveTileMaterial;
            break;
        case ActivationType.SUPPORTIVE:
            tileMaterial = SupportiveTileMaterial;
            break;
        default: goto case ActivationType.DEFENSIVE; // Default is just blue
        }

        // Second determine how tiles are generated and generate them accordingly
        switch (rangeType) {
        case RangeType.SQUARERANGE:
            generateSquareRangeTiles(range, initialX, initialZ, tileMaterial);
            break;
        case RangeType.STRAIGHTLINERANGE:
            generateStraightLineTiles(range, initialX, initialZ, tileMaterial);
            break;
        default: goto case RangeType.SQUARERANGE; // Default is the square range
        }
    }
 public void SetActivationType(ActivationType type)
 {
     activation = type;
 }
Beispiel #44
0
        private List<double[]> SpreadClassificationAnswers(List<double[]> answers, ActivationType activation)
        {
            var newAnswers = new List<double[]>();
            var minValue = activation == ActivationType.Bipolar ? -1.0 : 0.0;

            LastLayerSize = answers.Select(a => a[0]).Distinct().Count();

            foreach (var answer in answers)
            {
                var newAnswer = new double[LastLayerSize];

                for (int i = 0; i < LastLayerSize; ++i)
                    newAnswer[i] = i+1 == (int) answer[0] ? 1 : minValue;

                newAnswers.Add(newAnswer);
            }

            return newAnswers;
        }
		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//   
        
		/// /// <summary>
		/// Constructor of ANN
		/// </summary>
		/// <param name="classId">Identification of a class label</param>
		public ANN(int classId)
		{
			this._class_id = classId;
			this._previousError = _threshold = 0.1;//double.Epsilon; 
			this._hiddenLayers = new ArrayList();
			this._inputVector = new ArrayList();
			this._graphPoints = new ArrayList();
			this._minimum = -0.5;
			this._maximum = 0.5;
			this._learningRate = 0.9;
			this._momentum = 1;
			this._errorFn = 2;
			this._activationFnType = ActivationType.Sigmoud;
			this._activationFunction = CreateActivationFunction.CreateActivationFnCLass( this._activationFnType );
			
		}
Beispiel #46
0
        private static String createUserLechuck(modelPortType modelPort)
        {
            UserType user = new UserType();
            user.name = createPolyStringType("lechuck");
            user.fullName = createPolyStringType("Ghost Pirate LeChuck");
            user.givenName = createPolyStringType("Chuck");
            user.familyName = createPolyStringType("LeChuck");
            user.honorificPrefix = createPolyStringType("Ghost Pirate");
            user.emailAddress = "*****@*****.**";
            user.telephoneNumber = "555-1234";
            user.employeeNumber = "emp1234";
            user.employeeType = new string[] { "UNDEAD" };
            user.locality = createPolyStringType("Monkey Island");
            user.credentials = createPasswordCredentials("4rrrrghhhghghgh!123");
            ActivationType activationType = new ActivationType();
            activationType.administrativeStatus = ActivationStatusType.enabled;
            user.activation = activationType;

            return createUser(modelPort, user);
        }
Beispiel #47
0
 /// <summary>
 /// Konstruktor.
 /// </summary>
 /// <param name="interfaceType">Schnittstellentyp der Komponente</param>
 /// <param name="intializationHandler">Delegat auf Inizialisierungsfunktion</param>        
 /// <param name="moduleName">Modulname</param>
 /// <param name="activationType">Aktivierungsart</param>
 public ComponentRegistration(Type interfaceType, Func<object> intializationHandler, string moduleName, ActivationType activationType)
     : this()
 {
     // Werte übernehmen
     this.InterfaceType = interfaceType;
     this.InitializationHandler = intializationHandler;
     this.ModuleName = moduleName;
     this.ActivationType = activationType;
 }
Beispiel #48
0
 /// <summary>
 /// Creates a new instance of the ComponentRegistration class.
 /// </summary>
 /// <param name="interfaceType">Interface type of the component</param>
 /// <param name="intializationHandler">Delegate of initialization method</param>
 /// <param name="uniqueName">Unique component name</param>
 /// <param name="activationType">Activation type (Singleton/SingleCall)</param>
 /// <param name="cleanUpHandler">Delegate of clean up method</param>
 public ComponentRegistration(Type interfaceType, Func<object> intializationHandler, string uniqueName, ActivationType activationType, Action<object> cleanUpHandler)
     : this()
 {
     this.InterfaceType = interfaceType;
     this.InitializationHandler = intializationHandler;
     this.UniqueName = uniqueName;
     this.ActivationType = activationType;
     this.CleanUpHandler = cleanUpHandler;
     this.EventStub = new EventStub(InterfaceType);
 }
Beispiel #49
0
        private void Normalize(List<double[]> data, double[] mins, double[] maxes, ActivationType activation)
        {
            var min = ActivationType.Bipolar == activation ? -1.0 : 0.0;
            var max = 1.0;
            var norm = max - min;

            for (int i = 0; i < data[0].Length; ++i)
            {
                var size = maxes[i] - mins[i];

                foreach (var item in data)
                    item[i] = ((item[i] - mins[i]) * norm / size) + min;
            }
        }
Beispiel #50
0
        public void TestModel(string testDataPath, BasicNetwork model, ProblemType problem, ActivationType activation)
        {
            TestDataPath = testDataPath;
            var csvReader = new ReadCSV(testDataPath, true, CSVFormat.DecimalPoint);

            var values = new List<double[]>();
            var originalValues = new List<double[]>();

            while (csvReader.Next())
            {
                values.Add(ProblemType.Classification == problem
                    ? new[] {csvReader.GetDouble(0), csvReader.GetDouble(1)}
                    : new[] {csvReader.GetDouble(0)});

                originalValues.Add(ProblemType.Classification == problem
                    ? new[] { csvReader.GetDouble(0), csvReader.GetDouble(1) }
                    : new[] { csvReader.GetDouble(0) });
            }

            csvReader.Close();

            Normalize(values, _valuesMins, _valuesMaxes, activation);

            var answers = new List<double>();
            foreach (var value in values)
            {
                var answer = new double[LastLayerSize];
                model.Compute(value, answer);
                answers.Add(problem == ProblemType.Regression ? DenormalizeAnswer(answer[0], activation) : GetClassFromAnswer(answer));
            }

            AnswerPath = Path.GetFullPath(TestDataPath) + ".solved";

            var lines = new List<string>();
            lines.Add(problem == ProblemType.Classification ? "x,y,clc" : "x,y");

            lines.AddRange(answers.Select((t, i) =>
                problem == ProblemType.Regression
                ? originalValues[i][0].ToString(CultureInfo.InvariantCulture) + "," + t.ToString(CultureInfo.InvariantCulture)
                : originalValues[i][0].ToString(CultureInfo.InvariantCulture) + "," + originalValues[i][1].ToString(CultureInfo.InvariantCulture) + "," + t.ToString(CultureInfo.InvariantCulture)));

            File.WriteAllLines(AnswerPath, lines);
        }
Beispiel #51
0
 /// <summary>
 /// Creates a new instance of the ComponentRegistration class.
 /// </summary>
 /// <param name="interfaceType">Interface type of the component</param>
 /// <param name="intializationHandler">Delegate of initialization method</param>
 /// <param name="activationType">Activation type (Singleton/SingleCall)</param>
 public ComponentRegistration(Type interfaceType, Func<object> intializationHandler, ActivationType activationType)
     : this()
 {
     this.InterfaceType = interfaceType;
     this.InitializationHandler = intializationHandler;
     this.ActivationType = activationType;
     this.UniqueName = interfaceType.FullName;
     this.EventStub = new EventStub(InterfaceType);
 }