My main code in my header file:
UCLASS(BlueprintType)
class DIVERGENTNEURALNET_API Neuron
{
public:
GENERATED_BODY()
Neuron(int toldLayerNumber, int toldSectionNumber, int totalNumLayersInSection, ESectionType sectionType);
int layerNumber;
int sectionNumber;
float value;
ELayerType layerType;
ESectionType sectionType;
// From x to x+1 layer
UFUNCTION(BlueprintCallable)
void FeedForward(TArray<Synapse>* FSynapses, TArray<Neuron>* FinputLayers, Finput FinputValue);
};
cpp file:
Neuron::Neuron(int toldLayerNumber, int toldSectionNumber, int totalNumLayersInSection, ESectionType sectionType)
{
layerNumber = toldLayerNumber;
sectionNumber = toldSectionNumber;
//By default, the layer type will be hidden.
layerType = ELayerType::Hidden;
inputImage = input.sourceImage;
// total numbers of layers in section variable will be handled by the Net class.
// This class is handling the neuron's functionality and the FSynapses between neurons.
// Determines the layer type for each instance of the class so it knows its inputs and outputs if necessary
if (toldLayerNumber == 0) {
layerType = ELayerType::Input;
}
else if (toldLayerNumber >= totalNumLayersInSection) {
layerType = ELayerType::Output;
}
else{
layerType = ELayerType::Hidden;
}
}
void Neuron::FeedForward(TArray<Synapse>* FSynapses,TArray<Neuron>* InputLayers,FinputinputValue) {
int n = 0;
UTexture2D inputImage = inputValue.soureImage;
const FColor* FormatedImageData = static_cast<const FColor*>(inputImage->PlatformData->Mips[0].BulkData.LockReadOnly());
for (i InputLayers : array) {
i.value = FormatedImageData[n];
++n;
}
inputImage->PlatformData->Mips[0].BulkData.Unlock();
}