Spaces:
Sleeping
Sleeping
File size: 1,107 Bytes
2c6b73d 5fcecfa dcb0894 a95ae71 2c6b73d 78a18f0 2c6b73d 78a18f0 2c6b73d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import SpecialFunctions: gamma, lgamma, erf, erfc, beta
# Define allowed operators. Any julia operator can also be used.
plus(x::Float32, y::Float32)::Float32 = x+y #Do not change the name of this operator.
mult(x::Float32, y::Float32)::Float32 = x*y #Do not change the name of this operator.
pow(x::Float32, y::Float32)::Float32 = sign(x)*abs(x)^y
div(x::Float32, y::Float32)::Float32 = x/y
logm(x::Float32)::Float32 = log(abs(x) + 1f-8)
logm2(x::Float32)::Float32 = log2(abs(x) + 1f-8)
logm10(x::Float32)::Float32 = log10(abs(x) + 1f-8)
sqrtm(x::Float32)::Float32 = sqrt(abs(x))
neg(x::Float32)::Float32 = -x
function greater(x::Float32, y::Float32)::Float32
if x > y
return 1f0
end
return 0f0
end
function relu(x::Float32)::Float32
if x > 0f0
return x
end
return 0f0
end
function logical_or(x::Float32, y::Float32)::Float32
if x > 0f0 || y > 0f0
return 1f0
end
return 0f0
end
# (Just use multiplication normally)
function logical_and(x::Float32, y::Float32)::Float32
if x > 0f0 && y > 0f0
return 1f0
end
return 0f0
end
|