Recent

Author Topic: AI, NLP and CAI: Text Generation with Convolutional Neural Networks in Pascal  (Read 19450 times)

indydev

  • Jr. Member
  • **
  • Posts: 96
After looking into it. It looks like OpenAI removed the assistant sharing quite some time ago. Probably because the API is tied to accounts and thus charges would be applied to the Assistant owner.

schuler

  • Full Member
  • ***
  • Posts: 234
Quote
What I'm looking for is how to divide a layer into two branches and join one of the two branches further into another layer.
@Dzandaa,
For CIFAR-10 32x32x3 images, this is an example showing how to create 3 branches being one branch for each channel: R, G and B:

Code: Pascal  [Select][+][-]
  1.         InputLayer := NN.AddLayer( TNNetInput.Create(32,32,3) );        
  2.        
  3.         // Branch1
  4.         NN.AddLayerAfter( TNNetSplitChannels.Create([0]), InputLayer);
  5.         NN.AddLayer( TNNetConvolutionReLU.Create(FeaturesNum, FeatureSize, iInputPadding, Stride) );
  6.         NN.AddLayer( TNNetMaxPool.Create(4) );
  7.         Branch1 := NN.AddLayer(TNNetConvolutionReLU.Create(21, iInnerConvFeatureSize, iPadding, 0));
  8.  
  9.         // Branch2
  10.         NN.AddLayerAfter( TNNetSplitChannels.Create([1]), InputLayer);
  11.         NN.AddLayer( TNNetConvolutionReLU.Create(FeaturesNum, FeatureSize, iInputPadding, Stride) );
  12.         NN.AddLayer( TNNetMaxPool.Create(4) );
  13.         Branch2 := NN.AddLayer(TNNetConvolutionReLU.Create(22, iInnerConvFeatureSize, iPadding, 0));
  14.  
  15.         // Branch3
  16.         NN.AddLayerAfter( TNNetSplitChannels.Create([2]), InputLayer);
  17.         NN.AddLayer( TNNetConvolutionReLU.Create(FeaturesNum, FeatureSize, iInputPadding, Stride) );
  18.         NN.AddLayer( TNNetMaxPool.Create(4) );
  19.         Branch3 := NN.AddLayer( TNNetConvolutionReLU.Create(21, iInnerConvFeatureSize, iPadding, 0) );
  20.  
  21.         NN.AddLayer( TNNetDeepConcat.Create([Branch1, Branch2, Branch3]) );
  22.  
  23.         if fDropout > 0 then NN.AddLayer( TNNetDropout.Create(fDropout) );
  24.  
  25.         NN.AddLayer( TNNetLayerStdNormalization.Create() );
  26.         NN.AddLayer( TNNetConvolutionReLU.Create(iConvNeuronCount, iInnerConvFeatureSize, iPadding, 0) );
  27.  
  28.         NN.AddLayer( TNNetFullConnectReLU.Create(32) );
  29.         NN.AddLayer( TNNetFullConnectReLU.Create(32) );
  30.         NN.AddLayer( TNNetFullConnectLinear.Create(NumClasses) );
  31.         NN.AddLayer( TNNetSoftMax.Create() );

The example above uses TNNetSplitChannels and TNNetDeepConcat. The other way of branching (very popular with Keras/PyTorch) is using pointwise convolutions or just any convolution for splitting:
Code: Pascal  [Select][+][-]
  1.        
  2.         InputLayer := NN.AddLayer( TNNetInput.Create(32,32,3) );        
  3.  
  4.         // Branch1 (3x3 features)
  5.         Branch1 := NN.AddLayerAfter(TNNetConvolutionReLU.Create(FeaturesNum, 3, 1, Stride),InputLayer);
  6.  
  7.         // Branch2 (5x5 features)
  8.         Branch2 := NN.AddLayerAfter(TNNetConvolutionReLU.Create(FeaturesNum, 5, 2, Stride),InputLayer);
  9.  
  10.         // Branch3 (7x7 features)
  11.         Branch3 := NN.AddLayerAfter(TNNetConvolutionReLU.Create(FeaturesNum, 7, 3, Stride),InputLayer);
  12.  
  13.         // Concats all 3 branches so the NN has only one end.
  14.         NN.AddLayer(TNNetDeepConcat.Create([Branch1, Branch2, Branch3]));        
  15.         NN.AddLayer( TNNetFullConnectLinear.Create(NumClasses) );
  16.         NN.AddLayer( TNNetSoftMax.Create() );
« Last Edit: April 25, 2024, 05:58:07 pm by schuler »

schuler

  • Full Member
  • ***
  • Posts: 234
Regarding the chatGPT interface version. Is that available as an assistant in the playground? I don't have a PRO account, but use the API through my (still limited) client.

I probably should create another slightly downgraded assistant that could be used for free (without paid subscription) at poe.com. What do you think?

Dzandaa

  • Sr. Member
  • ****
  • Posts: 305
  • From C# to Lazarus
Hi
@schuler

Just what I need, thank you very much!!!

B->
Dzandaa

indydev

  • Jr. Member
  • **
  • Posts: 96
Regarding the chatGPT interface version. Is that available as an assistant in the playground? I don't have a PRO account, but use the API through my (still limited) client.

I probably should create another slightly downgraded assistant that could be used for free (without paid subscription) at poe.com. What do you think?

That would work. Thank you.

schuler

  • Full Member
  • ***
  • Posts: 234
@indydev,
As requested, the free version is ready to use:
https://poe.com/CAI-NEURAL-API-FREE

indydev

  • Jr. Member
  • **
  • Posts: 96
@indydev,
As requested, the free version is ready to use:
https://poe.com/CAI-NEURAL-API-FREE

Nice! I have had just a short time with this on poe.com. I can see that there is some length limitation with poe that I get around by asking it to continue. It is very good at providing answers and examples to simple questions. But when I uploaded some code (Javascript and Free Pascal) and asked it to evaluate the translation it responded in Spanish (perhaps seeing "translation" or "rewrite" as a request to change the human interactive language). https://poe.com/s/kR9wcAfZ8ezLcLkeJw1A Requesting it in english fixed that problem. However, I finished up my free usage rather quickly. The response is pretty impressive--especially the speed. Thanks.

avra

  • Hero Member
  • *****
  • Posts: 2517
    • Additional info
As requested, the free version is ready to use:
https://poe.com/CAI-NEURAL-API-FREE
That is fun to play with  8-)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

schuler

  • Full Member
  • ***
  • Posts: 234
@indydev,
Regarding the Spanish, I got the same problem here.

You now should be able to use the openai version for free:

https://chatgpt.com/g/g-bqMxEDpIg-neural-api-free-pascal-developer

You can try general pascal coding tasks if you like (besides AI tasks).

I think that you'll be able to use without paying because I got the following email in my inbox:

Quote
Today, GPTs in the Store are now available to all ChatGPT users, allowing more than 100 million weekly active users to experience your GPT and the others in the store.


indydev

  • Jr. Member
  • **
  • Posts: 96
I was just going to let you know that I found the chatGPT version available a couple of days ago. I get more use from it here than with POE.  I haven't looked at your contribution at Hugging Face, other than to see that it is there, but I want to look at it to see what you have done.  When I use the chatGPT version, it does seem to do better than the normal version. Thank you so much!

I am also very much interested in TLMs since it might be possible to run them locally, reducing the need to reach out to an LLM.

 

TinyPortal © 2005-2018