This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
set.seed(123)
# Define weights
# Weights for the hidden layer (3 neurons)
w11 <- 0.1
w12 <- 0.2
w13 <- 0.3
w21 <- 0.4
w22 <- 0.5
w23 <- 0.6
# Added weights for the missing connections
w31 <- 0.7
w32 <- 0.8
# Weights for the output layer
w_o1 <- 0.5
w_o2 <- 0.3
w_o3 <- 0.2
# Define activation function (Identity function for simplicity)
activation <- function(x) {
return(x)
}
# Function to calculate the output of the neural network
neural_network_output <- function(input1, input2) {
# Hidden layer activations
a1 <- activation(w11 * input1 + w12 * input2)
a2 <- activation(w12 * input1 + w22 * input2)
a3 <- activation(w13 * input1 + w32 * input2)
# Output layer
output <- w_o1 * a1 + w_o2 * a2 + w_o3 * a3
return(output)
}
# Sample data
data <- data.frame(input1 = c(0.1, 0.2), input2 = c(0.2, 0.3))
# Generate predictions
predictions <- mapply(neural_network_output, data$input1, data$input2)