After searching through various resources, mostly from stackoverflow. I am able to get my code working on following python versions on my laptop (with Windows 10 installed) 1. WinPython3.4 64 bit 2. WinPython3.4 32 bit 3. Python 2.7 32 bit and in its virtualenv 4. Python 2.7 64 bit and in its virtualenv
Then I wanted it to deploy to aws lambda. for that I tried following two options for all above options one by one 1. Just zip .py file for the code and the referenced dll 2. zip .py file for the code and the referenced dll with 3 & 4 virtualenv
But in all these cases I am getting "module initialization error: /var/task/TDNN.dll: invalid ELF header " error message in cloudwatch.
I looked around but i did not find any solution. I would appreciate for any help/pointer. Thnx in advance.
Below is the code
import json
import urllib
import re
import os, sys
import datetime
import math
from math import *
import csv
import time
#import boto3
import ctypes
from ctypes import *
#s3 = boto3.client('s3')
NNepochs=50
inputDataL= [0,0,0,1,0,1,1,0]
desiredDataL= [0,1,1,0,0,0,0,1]
CVInputDataL= [0,0,0,1,0,1,1,0]
CVDesiredDataL= [0,0,0,1,0,1,1,0]
inputData = (ctypes.c_float * len(inputDataL))(*inputDataL)
desiredData = (ctypes.c_float * len(desiredDataL))(*desiredDataL)
CVInputData = (ctypes.c_float * len(CVInputDataL))(*CVInputDataL)
CVDesiredData = (ctypes.c_float * len(CVDesiredDataL))(*CVDesiredDataL)
outputData = (ctypes.c_float * len(desiredDataL))(*desiredDataL)
## NN starts here
#keytdnndll = 'D:/Documents/1. Vultures Pick/AmazonCloud/QCollector/NIFTY/STP/TDNN/TDNN.dll'
keytdnndll='TDNN.dll'
TDNNdll=ctypes.cdll.LoadLibrary(keytdnndll)
createNetwork=getattr(TDNNdll,'createNetwork')
#print(createNetwork, callable(createNetwork))
TDNN=ctypes.c_int()
#print('TDNN pointer', TDNN)
createNetwork(ctypes.byref(TDNN),1)
#print('TDNN pointer', TDNN)
resetNetwork=getattr(TDNNdll,'resetNetwork')
resetNetwork(TDNN)
trainNetwork=getattr(TDNNdll,'train')
setCrossValidationEnabled = getattr(TDNNdll,'setCrossValidationEnabled')
getCrossValidationEnabled = getattr(TDNNdll,'getCrossValidationEnabled')
crossValEnabled=ctypes.c_bool()
getCrossValidationEnabled(TDNN, ctypes.byref(crossValEnabled))
print('crossValEnabled',crossValEnabled)
#print(setCrossValidationEnabled, callable(setCrossValidationEnabled))
true=ctypes.c_char()
setCrossValidationEnabled(TDNN, ctypes.byref(true))
getCrossValidationEnabled(TDNN, ctypes.byref(crossValEnabled))
print('crossValEnabled',crossValEnabled)
epochs = ctypes.c_int(NNepochs)
print('epochs', epochs)
dl=len(inputDataL)
datalength = ctypes.c_int(dl)
print('datalength', datalength)
trainNetwork(TDNN,epochs,datalength,inputData,desiredData,datalength,CVInputData,CVDesiredData)
getEpochOfBestCost = getattr(TDNNdll,'getEpochOfBestCost')
epochnumber=ctypes.c_int()
getEpochOfBestCost(TDNN,ctypes.byref(epochnumber))
print('epochnumber', epochnumber)
getNumberOfEpochsTrained=getattr(TDNNdll, 'getNumberOfEpochsTrained')
epochtrained=ctypes.c_int()
getNumberOfEpochsTrained(TDNN,ctypes.byref(epochtrained))
print('epochtrained', epochtrained)
getResponse=getattr(TDNNdll,'getResponse')
getResponse(TDNN,datalength,inputData,outputData)
floatPtr = ctypes.cast(outputData, ctypes.POINTER(ctypes.c_float))
outputDataL = [floatPtr[i] for i in range(dl)]
print('outputDataL', outputDataL)
destroyNetwork=getattr(TDNNdll,'destroyNetwork')
destroyNetwork(TDNN)