Skip to content

Commit

Permalink
Merge branch 'patch/transferfunctions/logistic_offset' of https://git…
Browse files Browse the repository at this point in the history
…hub.com/PrincetonUniversity/PsyNeuLink into patch/transferfunctions/logistic_offset
  • Loading branch information
jdcpni committed Jan 25, 2025
2 parents f670b77 + 6abc15b commit 385e2d4
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1124,15 +1124,15 @@ def _gen_llvm_transfer(self, builder, index, ctx, vi, vo, params, state, *, tags
zero = ctx.float_ty(0)

if "derivative_out" not in tags:
val = builder.fadd(val, bias) # variable + bias
val = builder.fsub(val, x_0) # variable + bias - x_0
val = builder.fmul(val, gain) # gain * (variable + bias - x_0)
val = builder.fsub(zero, val) # <- fails
val = builder.call(exp_f, [val])
val = builder.fadd(ctx.float_ty(1), val)
val = builder.fdiv(ctx.float_ty(1), val)
val = builder.fmul(val, scale)
val = builder.fadd(val, offset)
val = builder.fadd(val, bias) # variable + bias
val = builder.fsub(val, x_0) # variable + bias - x_0
val = builder.fmul(val, gain) # gain * (variable + bias - x_0)
val = builder.fsub(zero, val) # -gain * (variable + bias - x_0)
val = builder.call(exp_f, [val]) # e^(-gain * (variable + bias - x_0))
val = builder.fadd(ctx.float_ty(1), val) # 1 + e^(-gain * (variable + bias - x_0))
val = builder.fdiv(ctx.float_ty(1), val) # 1 / (1 + e^(-gain * (variable + bias - x_0)))
val = builder.fmul(val, scale) # scale * (1 / (1 + e^(-gain * (variable + bias - x_0)))
val = builder.fadd(val, offset) # scale * (1 / (1 + e^(-gain * (variable + bias - x_0))) + offset

if "derivative" in tags or "derivative_out" in tags:
# f(x) = g * s * o * (1-o)
Expand Down

0 comments on commit 385e2d4

Please sign in to comment.