In R I have an R6 class with a predict method. When the predict method is called, it should run the tensorflow computation, here multiply inputs and weights.
This is the code:
NeuralNetworkTensorflow = R6::R6Class("NeuralNetworkTensorflow",
public = list(
inputs = NULL,
weights = NULL,
Q = NULL,
sess = NULL,
initialize = function() {
tf$reset_default_graph()
self$inputs = tf$placeholder(tf$float32, shape(1L, 5L))
self$weights = tf$Variable(tf$random_uniform(shape(5L, 4L), 0, 0.01))
self$Q = tf$matmul(self$inputs, self$weights)
self$sess = tf$Session()
self$sess$run(tf$global_variables_initializer())
},
predict = function(inputs) {
self$sess$run(self$Q, feed_dict = dict(inputs = inputs))
}
)
)
my_nn = NeuralNetworkTensorflow$new()
my_nn$predict(matrix(c(0, 1, 0, 0, 1), ncol = 5))
It returns the following error:
Error in py_call_impl(callable, dots$args, dots$keywords) :
SystemError: <built-in function TF_NewBuffer> returned a result with an error set
I'm not sure, what's going wrong here. Can someone help?