Recent

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

indydev

  • Jr. Member
  • **
  • Posts: 72
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: 232
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: 232
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: 272
  • From C# to Lazarus
Hi
@schuler

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

B->
Dzandaa

indydev

  • Jr. Member
  • **
  • Posts: 72
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.

 

TinyPortal © 2005-2018