/// <summary> /// The verify() method implementation for this class. See NNPannel.verify() for more documentation. /// </summary> /// <returns></returns> public override bool verify() { try { this.numNeurons = Convert.ToInt32(this.numNeuronsTB.Text); if (this.numNeurons < 1) { MessageBox.Show("Error: There must be at least one neuron in each layer."); return(false); } } catch { MessageBox.Show("Error: Cannot convert the number of neurons to a valid integral value"); return(false); } if (this.biasEnabled) { try { this.biasValue = Convert.ToDouble(this.biasValueTB.Text); } catch { MessageBox.Show("Error: Cannot convert the bias values to a valid floating point value."); return(false); } } else { this.biasValue = 0; } if (!this.isSyncLayer) { if (this.thresholdingEnabled) { this.asyncActivationType = this.validAsyncActivationTypes[this.activationComboBox.SelectedIndex]; } else { this.asyncActivationType = AsyncNeuron.NeuronActivationType.NONE; } } else { this.syncActivationType = this.validSyncActivationTypes[this.activationComboBox.SelectedIndex]; } this.isClassifier = this.binaryClassificationRadioButton.Checked; if (this.isClassifier && (this.classifierThresholds.Length != this.numNeurons || !this.verifiedClassifier)) { MessageBox.Show("Error: Number of classifier thresholds and number of neurons are not the same."); return(false); } return(true); }
/// <summary> /// Create a new instance of a memory implementation of a synchronous transfer function /// </summary> /// <param name="_numIntBits">The number of integer bits to use in the implementation</param> /// <param name="_numFracBits">The number of fractional bits to use in the implementation</param> /// <param name="_activationType">The transfer function to implement</param> /// <param name="_name">The name of the memory entity</param> public SyncTransferFunctionMem(int _numIntBits, int _numFracBits, TransferFunctionWrapper.MemoryActivationType _activationType, string _name) { this.numIntBits = _numIntBits; this.numFracBits = _numFracBits; this.activationType = _activationType; this.name = _name; this.addr = new Port(Port.portDirection.IN, "addr", Utilities.VHDLDataType.STD_LOGIC_VECTOR, this.numIntBits + this.numFracBits - 1, 0); this.data = new Port(Port.portDirection.OUT, "data", Utilities.VHDLDataType.STD_LOGIC_VECTOR, this.numIntBits + this.numFracBits, 0); this.clk = new Port(Port.portDirection.IN, "clk", Utilities.VHDLDataType.STD_LOGIC, 0, 0); return; }
/// <summary> /// Create a VisualizerLayer /// </summary> /// <param name="_numNeurons">The number of neurons in the layer</param> /// <param name="_asyncActivationType">For an asynchronous network, the activation type. Ignored for synchronous networks</param> /// <param name="_syncActivationType">For a synchronous network, the activation type. Ignored for asynchronous networks</param> /// <param name="_isSynchronous">A flag determining whether the network is synchronous or not</param> /// <param name="_layerName">The name of the layer</param> /// <param name="_isFirstLayer">A flag representing whether this layer is the first layer in the network. Used to mask the activation type</param> public VisualizerLayer(int _numNeurons, AsyncNeuron.NeuronActivationType _asyncActivationType, TransferFunctionWrapper.MemoryActivationType _syncActivationType, bool _isSynchronous, string _layerName, bool _isFirstLayer) { InitializeComponent(); /*Prevent resizing*/ this.MaximumSize = this.Size; this.MinimumSize = this.Size; this.numNeurons = _numNeurons; this.asyncActivationType = _asyncActivationType; this.syncActivationType = _syncActivationType; this.isSynchronous = _isSynchronous; this.layerName = _layerName; this.isFirstLayer = _isFirstLayer; if (!this.isFirstLayer) { if (!this.isSynchronous) { this.activationType_string = Utilities.GetDescription <AsyncNeuron.NeuronActivationType>(this.asyncActivationType); } else { this.activationType_string = Utilities.GetDescription <TransferFunctionWrapper.MemoryActivationType>(this.syncActivationType); } } this.layerNameLabel.Text = String.Format("{0}", this.layerName); this.numNeuronLabel.Text = String.Format("{0} neurons", this.numNeurons); if (this.isSynchronous) { this.syncLabel.Text = "Synchronous"; } else { this.syncLabel.Text = "Asynchronous"; } if (this.isFirstLayer) { this.activationTypeLabel.Text = ""; } else { this.activationTypeLabel.Text = String.Format("Activation type: {0}", this.activationType_string); } this.label_padding = this.Height - this.layerNameLabel.Height - this.numNeuronLabel.Height - this.activationTypeLabel.Height - this.syncLabel.Height; this.label_padding /= 5; return; }
/// <summary> /// Construct the layer setup form /// </summary> /// <param name="_titleString">The string to display in the title</param> /// <param name="_biasEnabled">The seed value for whether the bias node is enabled for this layer or not</param> /// <param name="_biasValue">The seed value for the bias value for this layer</param> /// <param name="_numNeuron">The seed value for the number of neurons in the layer</param> /// <param name="_thresholdingEnabled">A flag for determing whether thresholding is enabled in this layer</param> /// <param name="_asyncType">For asynchronous networks, the seed value for the activation type. This parameter is ingored for synchronous networks</param> /// <param name="_syncType">For synchronous networks, the seed value for the activation type. This parameter is ignored for the asynchronous networks</param> /// <param name="_isSyncLayer">A flag for setting whether this layer is synchronous or asynchronous</param> /// <param name="_isLastLayer">A flag for setting whether this is the last layer in the network or not</param> public LayerSetup(string _titleString, bool _biasEnabled, double _biasValue, int _numNeuron, bool _thresholdingEnabled, AsyncNeuron.NeuronActivationType _asyncType, TransferFunctionWrapper.MemoryActivationType _syncType, bool _isSyncLayer, bool _isLastLayer) { InitializeComponent(); this.TitleLabel.Text = _titleString; this.biasEnabled = _biasEnabled; this.thresholdingEnabled = _thresholdingEnabled; this.isSyncLayer = _isSyncLayer; this.isLastLayer = _isLastLayer; this.biasValue = _biasValue; this.biasValueTB.Text = this.biasValue.ToString(); this.numNeurons = _numNeuron; this.numNeuronsTB.Text = _numNeuron.ToString(); this.validAsyncActivationTypes = new List <AsyncNeuron.NeuronActivationType>(); this.validSyncActivationTypes = new List <TransferFunctionWrapper.MemoryActivationType>(); this.activationComboBox.Items.Clear(); if (!this.isSyncLayer) { if (this.thresholdingEnabled) { int index = 0; var actTypes = Enum.GetValues(typeof(AsyncNeuron.NeuronActivationType)).Cast <AsyncNeuron.NeuronActivationType>(); foreach (AsyncNeuron.NeuronActivationType type in actTypes) { if (type != AsyncNeuron.NeuronActivationType.NONE) { this.activationComboBox.Items.Add(Utilities.GetDescription <AsyncNeuron.NeuronActivationType>(type)); this.validAsyncActivationTypes.Add(type); if (type == _asyncType) { this.activationComboBox.SelectedIndex = index; } index++; } } } else { this.activationComboBox.Items.Add(Utilities.GetDescription <AsyncNeuron.NeuronActivationType>(AsyncNeuron.NeuronActivationType.NONE)); this.activationComboBox.SelectedIndex = 0; } } else { int index = 0; var actTypes = Enum.GetValues(typeof(TransferFunctionWrapper.MemoryActivationType)).Cast <TransferFunctionWrapper.MemoryActivationType>(); foreach (TransferFunctionWrapper.MemoryActivationType type in actTypes) { this.activationComboBox.Items.Add(Utilities.GetDescription <TransferFunctionWrapper.MemoryActivationType>(type)); this.validSyncActivationTypes.Add(type); if (type == _syncType) { this.activationComboBox.SelectedIndex = index; } index++; } } this.biasValueTB.Visible = this.biasEnabled; this.biasLabel.Visible = this.biasEnabled; this.activationComboBox.Visible = this.thresholdingEnabled; this.thresholdingLabel.Visible = this.thresholdingEnabled; if (!this.isLastLayer) { this.binaryClassificationRadioButton.Visible = false; this.realValuedRadioButton.Visible = false; this.OutputTypeLabel.Visible = false; this.browseForThresholdInputsButton.Visible = false; this.thresholdLabel.Visible = false; this.thresholdInputFileTextBox.Visible = false; } }