/// <summary> /// Creates the readout layer configuration. /// </summary> /// <param name="foldDataRatio">Specifies what part of available data to be used as the fold data.</param> /// <param name="numOfAttempts">Number of regression attempts. Each readout network will try to learn numOfAttempts times.</param> /// <param name="numOfEpochs">Number of training epochs within an attempt.</param> ReadoutLayerSettings CreateReadoutLayerCfg(double foldDataRatio, int numOfAttempts, int numOfEpochs) { //For each output field we will use prediction of two networks //First network having only Identity output neuron and associated the resilient back propagation trainer FeedForwardNetworkSettings ffNet1Cfg = new FeedForwardNetworkSettings(new AFAnalogIdentitySettings(), null, new RPropTrainerSettings(numOfAttempts, numOfEpochs) ); //Second network having Identity output neuron, hidden layer consisting of 5 LeakyReLU neurons //and associated the resilient back propagation trainer HiddenLayerSettings hiddenLayerCfg = new HiddenLayerSettings(5, new AFAnalogLeakyReLUSettings()); FeedForwardNetworkSettings ffNet2Cfg = new FeedForwardNetworkSettings(new AFAnalogIdentitySettings(), new HiddenLayersSettings(hiddenLayerCfg), new RPropTrainerSettings(numOfAttempts, numOfEpochs) ); //Create the cluster chain configuration for the forecast and the default configuration for the forecast task. CrossvalidationSettings crossvalidationCfg = new CrossvalidationSettings(foldDataRatio); TNRNetClusterRealNetworksSettings networksCfg = new TNRNetClusterRealNetworksSettings(ffNet1Cfg, ffNet2Cfg); TNRNetClusterRealSettings realClusterCfg = new TNRNetClusterRealSettings(networksCfg, new TNRNetClusterRealWeightsSettings()); TNRNetClusterChainRealSettings realClusterChainCfg = new TNRNetClusterChainRealSettings(crossvalidationCfg, new TNRNetClustersRealSettings(realClusterCfg)); TaskDefaultsSettings taskDefaultsCfg = new TaskDefaultsSettings(null, realClusterChainCfg); //Create readout unit configurations. We will forecast next High and Low prices. ReadoutUnitSettings highReadoutUnitCfg = new ReadoutUnitSettings("High", new ForecastTaskSettings()); ReadoutUnitSettings lowReadoutUnitCfg = new ReadoutUnitSettings("Low", new ForecastTaskSettings()); //Create readout layer configuration ReadoutLayerSettings readoutLayerCfg = new ReadoutLayerSettings(taskDefaultsCfg, new ReadoutUnitsSettings(highReadoutUnitCfg, lowReadoutUnitCfg ), null ); return(readoutLayerCfg); }
/// <summary> /// Creates the simplified configuration of the readout layer to solve the forecast task. /// </summary> /// <remarks> /// Supports the real numbers output only. /// </remarks> /// <param name="crossvalidationCfg">The crossvalidation configuration.</param> /// <param name="netCfg">The configuration of the FF network to be used in the cluster(s).</param> /// <param name="clusterChainLength">The number of chained clusters.</param> /// <param name="unitName">The readout unit names (the output field names).</param> public static ReadoutLayerSettings CreateForecastReadoutCfg(CrossvalidationSettings crossvalidationCfg, FeedForwardNetworkSettings netCfg, int clusterChainLength, params string[] unitName ) { if (netCfg == null) { throw new ArgumentNullException("netL1Cfg"); } List <ReadoutUnitSettings> unitCfgCollection = new List <ReadoutUnitSettings>(); foreach (string name in unitName) { unitCfgCollection.Add(new ReadoutUnitSettings(name, new ForecastTaskSettings())); } TNRNetClusterRealNetworksSettings netsCfg = new TNRNetClusterRealNetworksSettings(netCfg); TNRNetClusterRealSettings clusterCfg = new TNRNetClusterRealSettings(netsCfg, new TNRNetClusterRealWeightsSettings()); List <TNRNetClusterRealSettings> clusterCfgCollection = new List <TNRNetClusterRealSettings>(); for (int i = 0; i < clusterChainLength; i++) { clusterCfgCollection.Add(clusterCfg); } TNRNetClustersRealSettings clustersCfg = new TNRNetClustersRealSettings(clusterCfgCollection); TNRNetClusterChainRealSettings clusterChainCfg = new TNRNetClusterChainRealSettings(crossvalidationCfg, clustersCfg); TaskDefaultsSettings taskDefaultsCfg = new TaskDefaultsSettings(null, clusterChainCfg); return(new ReadoutLayerSettings(taskDefaultsCfg, new ReadoutUnitsSettings(unitCfgCollection), null )); }