我想要獲取指數函數的值給我的代碼,但我不知道如何編寫Java中的指數函數。在Java中編寫指數函數的方法是什麼?如何獲取java中指數函數的值以及如何對指數函數進行編碼
public class Demo {
// inputs are declared
private int x[] = {1, 0, 1, 0};
//weights are declared
private double w[] = {0.4, 0.6, 0.7, 0.8};
private double temp = 0;
private double z = 0;
private int desiredOutput[] = {0, 1, 1, 1};
private double sigmoidOutput[] = {1, 1, 1, 1};
public void calculate() {
for(int i =0; i < 4; i++) {
temp = x[i] * w[i];
z += temp;
}
/*
I want to get the value of 1/(1+e to the power (-z))
*/
}
}
提到我們不能爲你做你的功課。你可以做的是向我們展示你迄今爲止所寫的內容,以及你的理解。然後我們可以幫助你。 – Kon
對不起,我問了這個問題,因爲我真的不知道如何在java中編寫指數值。這裏是我的代碼 –
試試這個:http://www.tutorialspoint.com/java/number_exp.htm –