diff --git a/main.c b/main.c index 700a7c4..b642158 100644 --- a/main.c +++ b/main.c @@ -47,17 +47,14 @@ void backup_weights(char filename[], double hiddenWeights[NUM_INPUTS][NUM_HIDDEN fprintf(fpt, "%f,", hiddenWeights[k][j]); } } - printf("Final Hidden Biases: \n"); for(int j = 0; j < NUM_HIDDEN; j++){ fprintf(fpt, "%f,", hiddenLayerBias[j]); } - printf("Final Output Weights: \n"); for(int j = 0; j < NUM_OUTPUTS; j++){ for(int k = 0; k < NUM_HIDDEN; k++){ fprintf(fpt, "%f,", outputWeights[k][j]); } } - printf("Final Output Biases: \n"); for(int j = 0; j < NUM_OUTPUTS; j++){ fprintf(fpt, "%f,", outputLayerBias[j]); } @@ -234,4 +231,4 @@ int main(){ return 0; -} \ No newline at end of file +} diff --git a/use.c b/use.c index 9d3ac7b..cb2350d 100644 --- a/use.c +++ b/use.c @@ -8,7 +8,7 @@ void getvalues(char filename[], double **HiddenWeights, double *HiddenBiases, do double sigmoid(double x); double sigmoid_derivative(double x); -int main() { +int main(int argc, char *argv[]) { // Allocate memory for weights and biases double **HiddenWeights = (double **)malloc(2 * sizeof(double *)); for (int i = 0; i < 2; i++) { @@ -23,11 +23,21 @@ int main() { // Load weights and biases from CSV file getvalues("weights.csv", HiddenWeights, HiddenBiases, FinalOutputWeights, FinalOutputBiases); + if (argc < 2) { + fprintf(stderr, "No arguments provided.\n"); + return EXIT_FAILURE; + } + if (argc != 3) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + double input1 = atof(argv[1]); + double input2 = atof(argv[2]); // Prompt user for input values - double input1, input2; - printf("Enter two values to compute XOR: "); - scanf("%lf %lf", &input1, &input2); + // double input1, input2; + // printf("Enter two values to compute XOR: "); + // scanf("%lf %lf", &input1, &input2); // Perform forward pass double hiddenLayer[2]; @@ -95,4 +105,4 @@ double sigmoid(double x) { double sigmoid_derivative(double x) { return x * (1.0 - x); -} \ No newline at end of file +}