rstudio / tensorflow

TensorFlow for R
https://tensorflow.rstudio.com
Apache License 2.0
1.32k stars 317 forks source link

Replicating tensorflow bert model in R #544

Open ozturkib opened 1 year ago

ozturkib commented 1 year ago

Stackoverflow question is here. I am just replicating this code based on Basic Text Classification. Until the below line, it seems alright. However, the following line:

vectorize_layer %>% adapt(train_text)

throws me an error as below. Any idea, how should I approach it in order to solve it ? My tensorflow version is TensorFlow v2.8.2, is it the main issue for this error ? It is not! Because I have also recreate new environment with v2.9.1, nothing is changed.

I assume that the train_textshould not be like that as well, should it ?

> train_text
<MapDataset element_spec=TensorSpec(shape=(None,), dtype=tf.string, name=None)>
The thrown error:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
RuntimeError: in user code:

File "C:\ANACON~2\envs\R-TENS~1\lib\site-packages\keras\engine\base_preprocessing_layer.py", line 118, in adapt_step *
self.update_state(data)
File "C:\ANACON~2\envs\R-TENS~1\lib\site-packages\keras\layers\preprocessing\text_vectorization.py", line 431, in update_state **
self._lookup_layer.update_state(self._preprocess(data))
File "C:\ANACON~2\envs\R-TENS~1\lib\site-packages\keras\layers\preprocessing\text_vectorization.py", line 512, in _preprocess
inputs = self._standardize(inputs)
File "C:\Users\xxxxx\AppData\Local\R\win-library\4.2\reticulate\python\rpytools\call.py", line 21, in python_function
raise RuntimeError(res[kErrorKey])

RuntimeError: Evaluation error: attempt to apply non-function.
t-kalinowski commented 1 year ago

Hi, I just re-rendered the qmd on my local machine and it rendered without issue.

Perhaps this is a windows or conda specific issue? Can you please try under WSL and see if it works there?