expand_dims in R errors or alternatives

Viewed 48

I have a dataset which I've used in kaggle where I expand it from a shape of 100,5 to 1,100,5 using the 'expand_dims' function, below code as an example from kaggle:

library(keras)
library(tensorflow)
library(kerasR)
data <- read.csv("../input/data.csv", header = FALSE)
expanded <- expand_dims(data, axis = 0)

However when running this locally on a notebook in RStudio on my windows 10 machine I get varying errors depending on if I try expand_dims ons k_expand_dims. Examples below:

expanded <- expand_dims(data, axis = 0)

Ouput:

Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: integer argument expected, got float

4.stop(structure(list(message = "TypeError: integer argument expected, got float", call = py_call_impl(callable, dots$args, dots$keywords), cppstack = NULL), class = c("Rcpp::exception", "C++Error", "error", "condition")))

3.expand_dims at <array_function internals>#6

2.modules$np$expand_dims(a = a, axis = int32(axis))

1.expand_dims(data, axis = 0)

expanded <- k_expand_dims(data, axis = 0)

Output:

Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Attempt to convert a value (followed by the contents of the data file)

2.keras$backend$expand_dims(x = x, axis = as_axis(axis))

1.k_expand_dims(data, axis = 0)

I've tried to find out any areas that might cause this to be different as I was wondering if it was due to this being on windows rather than a linux backend like kaggle but to no avail.

Software Versions:

R 4.0.5, Keras 2.4.0.9, Python 3.7.10, numpy 1.19.2

If theres an alernative to be able to expand the array in R itself thats fine too. Its to be fed into a tensorflow model requiring the shape 1,100,5

Thanks for any help!

0 Answers
Related