I am trying to pass an inverse link function to a keras::layer_lambda layer in a keras functional model. The layer is inside a function where "link" is a parameter:
link_layer <- spatial_summing_layer %>%
keras::layer_lambda(stats::make.link(link)$linkinv,
name = "link_layer")
It works fine for "identity", "sqrt", "1/mu^2" and "inverse" (all do not use .Machine$double.eps), but when I try to use a different link ("log"), I get the following error:
Error in py_call_impl(callable, dots$args, dots$keywords) :
RuntimeError: Exception encountered when calling layer "link_layer" (type Lambda).
Evaluation error: missing value where TRUE/FALSE needed.
Call arguments received by layer "link_layer" (type Lambda):
• inputs=tf.Tensor(shape=(None, 867, 1), dtype=float32)
• mask=None
• training=None
I believe it must be something to do with the environments, but I have no idea how to resolve it, except for manually coding the link functions myself.
Related
I'm using a dataframe named DataUniv composed of 13 variables. When I try to run a correspondance analysis using FactoMineR :
dataUniv.CA = CA(dataUniv[,2:7],
col.sup=c(1,8:13))
It sends me back this error :
Error in `[.data.frame`(Xtot, , col.sup) : undefined columns selected
I don't really understand why it sent me back this type of error, as it seems that those columns are effectively defined, if I run :
View(dataUniv[,2:7])
View(dataUniv[,c(1,8:13)])
It returns something good...
I finally found it: the col.sup argument must contain columns that are included in the first argument.
Does anyone know if there is a change in how errors with PyEval_EvalCode work in CPython 3.7, compared to CPython 3.6?
Specifically, I am asking because the way errors are handled seems different now.
We have some python code as a PyObject (let's call it Super_py_code), which, in turn, after leaving Python context, might call different Python code (in a new Python context) in the form of a PyObject (let's call it Sub_py_code), and there's an error (syntax error or whatever) at a sub-function, like this:
PyEval_EvalCode(Super_py_code, ...)
-> calling, leaving the context now ->
PyEval_EvalCode(Sub_py_code, ...) * <- Error here
Up until Python 3.6, I used to get an error indicator (return value NULL, and PyErr_Occurred() / PyErr_Fetch() return useful error information) at both calls to PyEval_EvalCode, which allowed us to string the stack traces together.
With Python 3.7 (and also 3.8), however, I ONLY get an error indicator at the lower PyEval_EvalCode(Sub_py_code, ...), but I get no longer any error information at the calling function PyEval_EvalCode(Super_py_code, ...), so, the stack trace is effectively cut above Sub_py_code.
I couldn't find any information in the Python-documentation for PyEval_EvalCode that the error handling has changed, however, so...
Is this an error in Python, or am I missing something?
I am attempting to broadcast the log function in a script I am writing.
It is throwing a domain error
julia> log(100)
4.605170185988092
julia> log(-100)
ERROR: DomainError:
Is there a way around this at all? I have a mix of - , + in my array.
For real input the log function returns real numbers. If the log function were to promote the type of log(-100) automatically (to complex numbers) it would be type unstable.
You can do log(complex(-100)) to get complex output (or log.(complex.(array)) for your array of numbers).
I was running my code, when I received the following error message:
"Error in t-1: non-numeric argument to binary operator"
The error is in p[t]<-p[t-1] in the function:
p<-rep(0, dimension)
price<-function(n, dimension){
p[t]<-p[t-1]
...
}
this function is recalled into another function where p[t=0] is equal to 1. T represents the time at which an order is submitted. At the beginning, i.e. for t=0, p[t]<-1. I also tried to change p[t-1] into p[t] and p[t] into p[t+1], but it gives me the same error.
Could you please tell me how I can fix this error?
Thank you
I am starting to use the futile.logger package. There is a nice FATAL error logging that I would like to use in conjuction with stop.
But say I do :
stop(flog.fatal('crash for some reason'))
I get
[FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason
Error:
[FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason
How can I just stop (abort the program), after logging what the flog.fatal logged
So [FATAL] [2015-07-06 22:46:54] [base.stop] crash for some reason and that's it
Your question as stated seems trivial? Just do
flog.fatal('crash for some reason'); stop()
?
(I personally find futile.logger more useful for writing text messages to a file, not to the console, but also print the messages to the console with R's conditions message(), warning(), stop() etc.
The value returned by flog.fatal is a character vector (length 1) which stop prints.
res <- flog.fatal('crash for some reason')
print(res)
As alternative you can use ftry function from the futile.logger package.
> futile.logger::ftry(log("a"))
ERROR [2017-08-22 10:50:51] non-numeric argument to mathematical function
Error in log("a") : non-numeric argument to mathematical function