context("yan.neuronLogicalUnitInput")
test_that("propagation zero", {
model <- as.yan.neuronLogicalUnitInput(0)
expect_identical(c(0, 0, 0), propagation(model, c(0.5, 1, 2)))
})
test_that("propagation positive", {
model <- as.yan.neuronLogicalUnitInput(2)
expect_identical(c(1, 2, 4), propagation(model, c(0.5, 1, 2)))
nv <- propagation(model, 0.25)
nv2 <- propagation(model, 0.1)
expect_true(nv > 0 && nv2 > 0)
expect_true(nv < 1)
expect_true(nv2 < nv)
})
test_that("propagation negative", {
model <- as.yan.neuronLogicalUnitInput(-2)
expect_identical(c(4, 2, 1), propagation(model, c(0.5, 1, 2)))
nv <- propagation(model, 4)
nv2 <- propagation(model, 8)
expect_true(nv > 0 && nv2 > 0)
expect_true(nv < 1)
expect_true(nv2 < nv)
})
test_that("backpropagation zero", {
model <- as.yan.neuronLogicalUnitInput(0)
input <- c(0.5, 1, 2)
output <- c(0, 0, 0)
expect_identical(data.frame(
input = input,
output = output,
dX = c(0, 0, 0),
dCutOff = c(0, 0, 0)
), backpropagation(model, input, output))
})
test_that("backpropagation positive", {
model <- as.yan.neuronLogicalUnitInput(2)
input <- c(0.5, 1, 2)
output <- c(1, 2, 4)
expect_identical(data.frame(
input = input,
output = output,
dX = c(2, 2, 2),
dCutOff = c(0.5, 1, 2)
), backpropagation(model, input, output))
})
test_that("backpropagation negative", {
model <- as.yan.neuronLogicalUnitInput(-2)
input <- c(0.5, 1, 2)
output <- c(4, 2, 1)
expect_identical(data.frame(
input = input,
output = output,
dX = c(-8, -2, -0.5),
dCutOff = c(-2, -1, -0.5)
), backpropagation(model, input, output))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.