personalityson / VBANN

Machine learning library in VBA
Creative Commons Zero v1.0 Universal
3 stars 0 forks source link

Visual Basic 6 #1

Open sysmaya opened 2 weeks ago

sysmaya commented 2 weeks ago

There are still dinosaurs out there that use Visual Basic 6 and it would be perfect to be able to use its magnificent implementation. So functions like ImportDatasetFromWorksheet() are not useful within VB6, if we could train from array[rows][columns] it would be great. On behalf of those of us who have not yet become extinct, I ask you, please, to give us an implementation method in VB6 Thank you

sysmaya commented 2 weeks ago

Nope. There is no way to use the CopyMemory() function!! I also see that your implementation is very, very VBA and Excel-oriented... I tried but couldn't.

personalityson commented 2 weeks ago

Hi, Sysmaya!

Yes, sorry, I haven't tested it outside of VBA. You won't be able to save the model, since it saves to a worksheet. But the rest might work. You can initialize a dataset directly from arrays like this:

Dim adblTrainingInputs() As Double
Dim adblTrainingLabels() As Double
Dim adblTestInputs() As Double
Dim adblTestLabels() As Double
Dim oTrainingDataset As TensorDataset
Dim oTestDataset As TensorDataset
Dim oTrainingSet As DataLoader
Dim oTestSet As DataLoader
'Etc

'Let this be your arrays of type Double
ReDim adblTrainingInputs(1 To lInputSize, 1 To lNumSamplesInTraining)
ReDim adblTrainingLabels(1 To lLabelSize, 1 To lNumSamplesInTraining)
ReDim adblTestInputs(1 To lInputSize, 1 To lNumSamplesInTest)
ReDim adblTestLabels(1 To lLabelSize, 1 To lNumSamplesInTest)
'Fill the arrays somehow

Set oTrainingDataset = New TensorDataset
oTrainingDataset.Init
With oTrainingDataset
    .Add "Input", TensorFromArray(adblTrainingInputs)
    .Add "Label", TensorFromArray(adblTrainingLabels)
End With

Set oTestDataset = New TensorDataset
oTestDataset.Init
With oTestDataset
    .Add "Input", TensorFromArray(adblTestInputs)
    .Add "Label", TensorFromArray(adblTestLabels)
End With

Set oTrainingSet = DataLoader(oTrainingDataset, lBatchSize)
Set oTestSet = DataLoader(oTestDataset, lBatchSize)

Set m_oModel = Sequential(L2Loss(), SGDM())
m_oModel.Add InputNormalizationLayer(oTrainingSet)
m_oModel.Add FullyConnectedLayer(lInputSize, 100)
m_oModel.Add LeakyReLULayer()
m_oModel.Add FullyConnectedLayer(100, 1)
m_oModel.Fit oTrainingSet, oTestSet, lNumEpochs