Neural network in Swift

Well, short story, I was bored and decided to try and learn about neural networks. I have been doing C # for a year and now that I am learning Swift I have chosen to continue this language and follow this tutorial .

The problem is that it is in C (or C ++, I'm not sure) and that I don't know the language and I clearly don't have the courage to learn it now. Deriving, I understand things step by step, but still, not all of them. So the purpose of this thread is to regularly edit my question with new subqueries (exclude multiple posts) to convert this C ++ project to swift. Is this against SO rules?

Here are my first ones:

  • In Structures (see here ):

    C ++ code:

    struct SNeuron
    {
       int m_NumInputs; //var m_NumInputs:Int (Swift)
    
       vector<double> m_vecWeight; // var m_vecWeight:[Double] = [] (Swift)
    
       SNeuron(int NumInputs); // IS THS THE SAME AS init(numInputs:Int) ?
    
    };
    
          

  • My Sigmoid Function

    func Sigmoid(x:Double) -> Double
    {
        return 1/(1 + exp(-x))
    }
    
          

    (which should follow this function)

        inline double Sigmoid(double activation, double response); //inline ?
    
          

  • What does CParams :: mean ?

          //add in the bias
    
          netinput += m_vecLayers[i].m_vecNeurons[j].m_vecWeight[NumInputs-1] *
    
                      CParams::dBias; //?
    
          

  • Is Vector.push_back () "equal to" Array.append ?

      outputs.push_back(Sigmoid(netinput, CParams::dActivationResponse));
    
          

    transferred to

      outputs.append(Sigmoid(netinput)) 
    
          

  • Function declaration with syntax I don't understand:

        int GetNumberOfWeights()const; //const ?
    
          

Well ... I'm only on the first code page of the tutorial, so things might explain themselves in the future, but still, if anyone has time to help me, that would be great!

+3


source to share


1 answer


Since you seem to know C #, here is a nice tutorial in ANN that you can convert to Swift after that to C #



+2


source







All Articles