Results 1 to 4 of 4

Thread: Neural networks in VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    7

    Neural networks in VBA

    If you guys have some experience from Pytorch or other major deep learning frameworks, and have some time to spare, give my simple neural network project (maybe the first one in VBA?) a test run. Big plus if you can test it with OpenBLAS dll which you put inside the same folder as the Excel workbook and edit the dll path in BlasFunctions module -- OpenBLAS provides prebuilt binary packages here https://sourceforge.net/projects/ope...files/v0.3.27/:

    https://github.com/personalityson/VBANN

    Code:
    Option Explicit
    
    Const MODEL_NAME As String = "MyModel"
    
    Private m_oModel As Sequential
    
    Public Sub SetupAndTrain()
        Dim lBatchSize As Long
        Dim lNumEpochs As Long
        Dim oTrainingSet As DataLoader
        Dim oTestSet As DataLoader
        
        VerifyOpenBlasLibrary
        
        lBatchSize = 10
        lNumEpochs = 50
        
        Set oTrainingSet = DataLoader(ImportDatasetFromWorksheet("ConcreteTrain", 8, 1, True), lBatchSize)
        Set oTestSet = DataLoader(ImportDatasetFromWorksheet("ConcreteTest", 8, 1, True), lBatchSize)
        
        Set m_oModel = Sequential(L2Loss(), SGDM())
        m_oModel.Add FullyConnectedLayer(8, 200)
        m_oModel.Add LeakyReLULayer()
        m_oModel.Add FullyConnectedLayer(200, 100)
        m_oModel.Add LeakyReLULayer()
        m_oModel.Add FullyConnectedLayer(100, 50)
        m_oModel.Add LeakyReLULayer()
        m_oModel.Add FullyConnectedLayer(50, 1)
        m_oModel.Fit oTrainingSet, oTestSet, lNumEpochs
        Serialize MODEL_NAME, m_oModel
        
        Beep
    End Sub
    
    Public Sub ContinueTraining()
        Dim lBatchSize As Long
        Dim lNumEpochs As Long
        Dim oTrainingSet As DataLoader
        Dim oTestSet As DataLoader
    
        VerifyOpenBlasLibrary
        
        lBatchSize = 10
        lNumEpochs = 50
        
        Set oTrainingSet = DataLoader(ImportDatasetFromWorksheet("ConcreteTrain", 8, 1, True), lBatchSize)
        Set oTestSet = DataLoader(ImportDatasetFromWorksheet("ConcreteTest", 8, 1, True), lBatchSize)
        
        Set m_oModel = Unserialize(MODEL_NAME)
        m_oModel.Fit oTrainingSet, oTestSet, lNumEpochs
        Serialize MODEL_NAME, m_oModel
        
        Beep
    End Sub
    Thanks
    Last edited by drgs; Jul 30th, 2024 at 06:19 AM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    692

    Re: Neural networks in VBA

    Hi
    I am interested in NN.
    I have implemented a simple one in VB6 that can evolve using backpropagation or Neuroevolution. (all from scratch)
    https://www.vbforums.com/showthread....Neural-Network
    I would like to try yours because I think it is more advanced (Deep). And maybe it could also be used for "style transfer" on images.

    I have (sort of) never worked in VBA, so, do you have a VB6 version ?

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2012
    Posts
    7

    Re: Neural networks in VBA

    Quote Originally Posted by reexre View Post
    Hi
    I am interested in NN.
    I have implemented a simple one in VB6 that can evolve using backpropagation or Neuroevolution. (all from scratch)
    https://www.vbforums.com/showthread....Neural-Network
    I would like to try yours because I think it is more advanced (Deep). And maybe it could also be used for "style transfer" on images.

    I have (sort of) never worked in VBA, so, do you have a VB6 version ?

    Hi,
    For me it is the opposite -- I have never worked with VB6. I do rely on saving models to worksheets and reading data from worksheets, so I guess it won't work without modifications.

    I only have very basic layers to put together a MLP, but by its modular design it's only a matter of adding new layer classes...
    (Currently I'm trying to integrate an extra dll for vector math (Intel Performance Primitives) to speed things up, so I ended up rewriting a few thing.)

    For style transfer on images you need at least convolutional layers + pooling layers, I think. Plus, a way to read images from disc, with color channels and everything.
    It's possible, but not really what I intended it for

    Btw, curious to have a peek at your code, but cant seem to find any source...
    Last edited by drgs; Aug 17th, 2024 at 04:20 PM.

  4. #4
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    692

    Re: Neural networks in VBA

    Thank you for reply

    Quote Originally Posted by drgs View Post
    ...
    Btw, curious to have a peek at your code, but cant seem to find any source...
    it's in the #2 post NNandGA.zip

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width