Click here to Skip to main content
15,891,529 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Textbox keeps losing focus Pin
Dave Kreskowiak12-Sep-13 4:11
mveDave Kreskowiak12-Sep-13 4:11 
AnswerRe: Textbox keeps losing focus Pin
TnTinMn12-Sep-13 4:34
TnTinMn12-Sep-13 4:34 
GeneralRe: Textbox keeps losing focus Pin
CJotaO12-Sep-13 8:19
CJotaO12-Sep-13 8:19 
GeneralRe: Textbox keeps losing focus Pin
TnTinMn12-Sep-13 17:14
TnTinMn12-Sep-13 17:14 
GeneralRe: Textbox keeps losing focus Pin
CJotaO12-Sep-13 21:37
CJotaO12-Sep-13 21:37 
QuestionRetreive Data from sql server along with headers or column name Pin
ashu200112-Sep-13 1:24
ashu200112-Sep-13 1:24 
AnswerRe: Retreive Data from sql server along with headers or column name Pin
Dave Kreskowiak12-Sep-13 4:03
mveDave Kreskowiak12-Sep-13 4:03 
QuestionUsing Func(Of TResult) Delegate Pin
Dominick Marciano6-Sep-13 19:14
professionalDominick Marciano6-Sep-13 19:14 
I'm building a neural network library pretty much to see if I can do it and advance my skills in programming. I'm currently building the Neuron class, and as you may or may not know, a neuron in a neural network has what's called an activation function; however my question below does not have to do with neural networks directly, strictly with the use of Func(Of TResult) delegate So within my neural network class I have several built in activation functions:
VB
Private Function Identity(value As Double) As Double
       Return value
   End Function

   Private Function [Step](value As Double) As Double
       If value <= 0 Then
           Return 0
       Else
           Return 1
       End If
   End Function

   Private Function LogarithmicSigmoid(value As Double, alpha As Double) As Double
       If value < -45.0 Then
           Return 0
       ElseIf value > 45.0 Then
           Return 1
       Else
           Return (1.0 / (1.0 + Exp(-alpha * value)))
       End If
   End Function

   Private Function SymmetricSigmoid(value As Double) As Double
       Return HyperbolicTangent(value)
   End Function

   Private Function HyperbolicTangent(value As Double) As Double
       If value < -45 Then
           Return -1.0
       ElseIf value > 45.0 Then
           Return 1.0
       Else
           Return Tanh(value)
       End If
   End Function


I also have an enumeration for the user to select which activation function they want to use for the neuron:
VB
Public Enum ActivationFunctions
        IDENTITY
        [STEP]
        LOGARITHMIC_SIGMOID
        SYMMETRIC_SIGMOID
        HYPERBOLIC_TANGENT
    End Enum


The first problem I'm having is with the following methods:
VB
Private activationFunction As Func(Of Double)

Public Sub SetActivationFunction(activationFunction As ActivationFunctions, value As Double, Optional alpha As Double = 1)
        Select Case activationFunction
            Case ActivationFunctions.IDENTITY
                Me.activationFunction = Function(value As Double) '<---PROBLEM LINE
        End Select
End Sub

Public Sub SetActivationFunction(ByVal activationFunction As Func(Of Double))
        'DON'T KNOW WHAT TO DO HERE
End Sub


I can't figure out how to set the instance variable activationFunction to a specific method using the AddressOf operator while passing it a parameter. Specifically in the first SetActivationFunction if the user passes the ActivationFunctions.IDENTITY enumeration, I would like to set the instance variable activationFunction to the method Identity but also pass the value parameter.

I've tried changing the line marked "PROBLEM LINE" to Me.activationFunction = AddressOf Identity but got the error message Method 'Private Function Identity(value As Double) As Double' does not have a signature compatible with delegate 'Delegate Function Func(Of Double)() As Double'.

If I changed it to Me.activationFunction = AddressOf Identity(value) the error message become 'AddressOf' operand must be the name of a method (without parentheses), and if I change it to Me.activationFunction = AddressOf Identity()(value) I get the error message Argument not specified for parameter 'value' of 'Private Function Identity(value As Double) As Double'

Based on the varying error message it seems like what I'm trying to do can be done, I just can't figure out the proper way to specify the argument for the Identity method while using the AddressOf operator.

Any help and guidance would be greatly appreciated. I should note that this is the first time I'm trying to use the Func(Of TResult) delegate in my own code, but since I want users to be able to supply their own methods and arguments for the parameters it seemed appropriate.

Thanks in advance for any help.
AnswerRe: Using Func(Of TResult) Delegate Pin
TnTinMn7-Sep-13 3:39
TnTinMn7-Sep-13 3:39 
GeneralRe: Using Func(Of TResult) Delegate Pin
Dominick Marciano8-Sep-13 3:28
professionalDominick Marciano8-Sep-13 3:28 
GeneralRe: Using Func(Of TResult) Delegate Pin
TnTinMn9-Sep-13 15:57
TnTinMn9-Sep-13 15:57 
QuestionDisable/enable ctrl+alt+del buttons and autorun. Pin
Otekpo Emmanuel5-Sep-13 14:13
Otekpo Emmanuel5-Sep-13 14:13 
AnswerRe: Disable/enable ctrl+alt+del buttons and autorun. Pin
Dave Kreskowiak5-Sep-13 18:25
mveDave Kreskowiak5-Sep-13 18:25 
GeneralHello Pin
Otekpo Emmanuel6-Sep-13 7:38
Otekpo Emmanuel6-Sep-13 7:38 
GeneralRequest Pin
Otekpo Emmanuel6-Sep-13 7:39
Otekpo Emmanuel6-Sep-13 7:39 
GeneralRe: Request Pin
Dave Kreskowiak6-Sep-13 14:31
mveDave Kreskowiak6-Sep-13 14:31 
AnswerRe: Disable/enable ctrl+alt+del buttons and autorun. Pin
Chris Quinn5-Sep-13 21:20
Chris Quinn5-Sep-13 21:20 
AnswerRe: Disable/enable ctrl+alt+del buttons and autorun. Pin
Eddy Vluggen6-Sep-13 9:26
professionalEddy Vluggen6-Sep-13 9:26 
QuestionDatabase connection using adodc control/autorun Pin
Otekpo Emmanuel5-Sep-13 13:57
Otekpo Emmanuel5-Sep-13 13:57 
AnswerRe: Database connection using adodc control/autorun Pin
Mycroft Holmes5-Sep-13 20:22
professionalMycroft Holmes5-Sep-13 20:22 
QuestionSound doesn't play instantly...but wait for next operation to complete!! Pin
Jayme653-Sep-13 3:17
Jayme653-Sep-13 3:17 
AnswerRe: Sound doesn't play instantly...but wait for next operation to complete!! Pin
Richard Deeming3-Sep-13 3:53
mveRichard Deeming3-Sep-13 3:53 
AnswerRe: Sound doesn't play instantly...but wait for next operation to complete!! Pin
Bernhard Hiller3-Sep-13 23:08
Bernhard Hiller3-Sep-13 23:08 
GeneralRe: Sound doesn't play instantly...but wait for next operation to complete!! Pin
Jayme655-Sep-13 21:23
Jayme655-Sep-13 21:23 
QuestionLate Binding issue in Copy Objects of AutoCAD Pin
Adnan Siddiqi1-Sep-13 9:42
Adnan Siddiqi1-Sep-13 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.