Recent

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

indydev

  • Jr. Member
  • **
  • Posts: 74
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: 233
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: 233
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: 279
  • From C# to Lazarus
Hi
@schuler

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

B->
Dzandaa

indydev

  • Jr. Member
  • **
  • Posts: 74
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: 233
@indydev,
As requested, the free version is ready to use:
https://poe.com/CAI-NEURAL-API-FREE

indydev

  • Jr. Member
  • **
  • Posts: 74
@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: 2516
    • 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

 

TinyPortal © 2005-2018