////////////////////MAKE INPUT VALUES////////////////////
double *NumOfInputsPointer = NULL;
std::cout << "How many inputs?" << std::endl;
int NumOfInputs;
std::cin >> NumOfInputs;
NumOfInputsPointer = new double[NumOfInputs];
std::cout << std::endl;
double InputVal;
for(int a = 0; a < NumOfInputs; a++)
{
std::cout << "What is the value for input " << a << std::endl;
a+1;
std::cin >> InputVal;
*(NumOfInputsPointer + a) = InputVal;
}
std::cout << std::endl;
////////////////////MAKE WEIGHTS////////////////////
double *NumOfWeightsPointer = NULL;
int NumOfWeights;
NumOfWeightsPointer = new double[NumOfWeights];
double WightVal;
for(int a = 0; a < NumOfInputs; a++)
{
*(NumOfWeightsPointer + a) = 0.5;
}
////////////////////Multiplication BRAIN BROKE!!!!!////////////////////
double *MultiplyPointer = NULL;
MultiplyPointer = NumOfInputsPointer;
for(int a = 0; a < NumOfInputs; a++)
{
//Stuff to do things
}
上面的代碼將製作單個人工神經元。我已經創建了一個與用戶想要的輸入數量組成陣列,然後自動使每個輸入權重爲0.5。從兩個陣列(人工神經元)乘以數值
我撞到的牆讓我拼命地將輸入值數組與它們的權重數組相乘,然後將這些數組保存在另一個數組中,以便將它們加在一起,然後通過修飾符。
我的努力是乘法並將其保存到數組中。我希望我能夠很好地解釋我的問題。
您使用'一個+ 1;'在第一個for循環。如果你想做增量,可以使用'a = a + 1;'或'a ++;'。 – Himanshu
分配你的新數組就像其他人一樣,然後'MultiplyPointer [a] = NumofInputsPointer [a] * NumOfWeightsPointer [a]'?還請閱讀std'vector' ...還請注意,在使用它之前,您沒有初始化'NumOfWeights' ...您的所有這些向量的意圖是相同的大小? –
@Guy Sirton:做出你所建議的改變,它完美運作!修正了NumOfWeights,並且一定會查看std :: vector。可能幫助清理我的代碼。 –