After searching for a few hours, I can't find any examples of text-based Neural Networks. Image processing is great and all but NLP is key to what I am building.
I tried several versions of what I cloud create for "NetEncoder" and "NetDecoder" to fix NLP but was unsuccessful. I tried leaving it out altogether hoping automatic would kick in and handle it for me.
I am assuming the data needs to be vectorized? I really like how Classify makes all this so much easier but I can not tolerate the training time. I must find a way to make the new NN's work for NLP because the Target->"GPU" is so much faster!
You can see the error I get at the bottom. I don't know how to create the NN configuration so it will work on text.
Here is my code:
dataSF = Import["E:\\Downloads\\Spam-Filter-CSV2.csv", "CSV"];
In[21]:= assocSF = Apply[Rule, dataSF, {1}];
In[22]:= trainLength = Round[Length[assocSF]*.3]
testLength = Round[Length[assocSF]*.7] + 1
Out[22]= 28923
Out[23]= 67487
In[24]:= trainingData = Take[assocSF, ;; trainLength];
testData = Take[assocSF, testLength ;;];
In[39]:= testData = RandomSample[trainingData, 10]
Out[39]= {"i can assist with mor info what about you" -> "NEUTRAL",
"i am just fired up to have received the txt these days" -> "OPTIN",
"how do your building reach your firm" -> "COMMERCIAL",
"i am just grateful for obtaining ur txts its remarkable" ->
"NEUTRAL", "hey there" -> "NEUTRAL",
"avoid the company texting" -> "OPTOUT",
"aww thanks swthart lov you as wll" -> "PERSONAL",
"i am just fired up to have attained that txt now" -> "OPTIN",
"cannot wait to see ya either" -> "PERSONAL",
"fairly great what about you" -> "NEUTRAL"}
neuralNet =
NetChain[{ConvolutionLayer[20, 5], Ramp, PoolingLayer[2, 2],
ConvolutionLayer[50, 5], Ramp, PoolingLayer[2, 2], FlattenLayer[],
500, Ramp, 10, SoftmaxLayer[]}]
trainedNN =
NetTrain[neuralNet, trainingData, ValidationSet -> testData,
MaxTrainingRounds -> 3, TargetDevice -> "GPU"]
Out[38]= Failure[NetTrain,
Association[
"MessageTemplate" :> MessageName[NetTrain, "invnet"],
"MessageParameters" :> {"First argument to NetTrain should be a fully specified net"}]]