public SimpleLayer(LayerConfig config) { LayerConfig = config; if (LayerSize % Vector <float> .Count != 0) { LayerSize += (Vector <float> .Count - (LayerSize % Vector <float> .Count)); } Cells = new float[LayerSize]; Errs = new float[LayerSize]; LabelShortList = new List <int>(); }
private void SetOutputLayers() { //Settings for output layer var outputLayer = config.GetValueRequired(OUTPUT_LAYER); var items = outputLayer.Split(':'); var sLayerType = items[0]; var outputLayerType = LayerType.None; foreach ( var type in Enum.GetValues(typeof(LayerType)) .Cast <LayerType>() .Where(type => sLayerType.Equals(type.ToString(), StringComparison.InvariantCultureIgnoreCase))) { outputLayerType = type; break; } if (IsCRFTraining == true && outputLayerType != LayerType.Simple) { throw new ArgumentException($"For RNN-CRF model, its output layer type must be simple layer."); } switch (outputLayerType) { case LayerType.Softmax: OutputLayerConfig = new SoftmaxLayerConfig(); Logger.WriteLine("Initialize configuration for softmax layer."); break; case LayerType.SampledSoftmax: var sampledSoftmaxLayerConfig = new SampledSoftmaxLayerConfig { NegativeSampleSize = int.Parse(items[1]) }; OutputLayerConfig = sampledSoftmaxLayerConfig; Logger.WriteLine( $"Initialize configuration for sampled Softmax layer. Negative sample size = '{sampledSoftmaxLayerConfig.NegativeSampleSize}'"); break; case LayerType.Simple: OutputLayerConfig = new SimpleLayerConfig(); Logger.WriteLine("Initialize configuration for simple layer."); break; default: Logger.WriteLine($"Invalidated output layer type {sLayerType}"); throw new ArgumentException($"Invalidated output layer type {sLayerType}"); } }
private void SetOutputLayers() { //Settings for output layer var outputLayer = config.GetValueRequired(OUTPUT_LAYER); var items = outputLayer.Split(':'); var sLayerType = items[0]; var outputLayerType = LayerType.None; foreach ( var type in Enum.GetValues(typeof(LayerType)) .Cast <LayerType>() .Where(type => sLayerType.Equals(type.ToString(), StringComparison.InvariantCultureIgnoreCase))) { outputLayerType = type; break; } switch (outputLayerType) { case LayerType.Softmax: var softmaxLayerConfig = new SoftmaxLayerConfig(); OutputLayerConfig = softmaxLayerConfig; Logger.WriteLine("Initialize configuration for softmax layer."); break; case LayerType.NCESoftmax: var nceLayerConfig = new NCELayerConfig { NegativeSampleSize = int.Parse(items[1]) }; OutputLayerConfig = nceLayerConfig; Logger.WriteLine( $"Initialize configuration for NCESoftmax layer. Negative sample size = '{nceLayerConfig.NegativeSampleSize}'"); break; } }
public LSTMLayer() { LayerConfig = new LayerConfig(); }
public NCEOutputLayer() { LayerConfig = new LayerConfig(); }
public BPTTLayer() { LayerConfig = new LayerConfig(); }
public SimpleLayer() { LayerConfig = new LayerConfig(); LabelShortList = new List <int>(); }
public SimpleLayer(LayerConfig config) { LayerConfig = config; AllocateMemoryForCells(); LabelShortList = new List <int>(); }