Open GarryGelade opened 5 years ago
UPDATE:
I updated my version of tensorFlow to v1.14.0,
devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow(){ }
Now I don't get the shape error. Looks like I am now getting the same sort of error reported in #740 by Sophia0616.
Error in py_call_impl(callable, dots$args, dots$keywords) : ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays: [array([[[ 767], [ 5], [ 9], [ 104], [ 450], [ 42], [ 767], [ 6539], [ 1968], [ 899], [ 899], [ ...
Detailed traceback: File "C:\Users\garry\ANACON~1\envs\R-RETI~1\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1433, in fit_generator steps_name='steps_per_epoch') File "C:\Users\garry\ANACON~1\envs\R-RETI~1\lib\site-packages\tensorflow\python\keras\engine\training_generator.py", line 264, in model_iteration batch_outs = batch_function(*batch_data) File "C:\Users\garry\ANACON~1\envs\R-RETI~1\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1153, in train_on_batch extract_tensors_from_dataset=True) File
UPDATE 2:
I save initial values of x and y to global variables by executing
x <<- transpose(skip$couples) %>% map(. %>% unlist %>% as.matrix(ncol = 1))
y <<- skip$labels %>% as.matrix(ncol = 1)
within the skipgram function. I then run the model without a fit generator or the skipgram function,
model %>% fit(x, y, epochs=1, batch_size = 32, validation_split = 0.2)
This runs fine, which suggests the output of skipgram is OK, but maybe fitgenerator is screwing up the output of skipgram?
I tried to reproduce the Keras word embedding example here https://blogs.rstudio.com/tensorflow/posts/2017-12-22-word-embeddings-with-keras/ along with the updated skip_grams_generator function #740
Here is the relevant code:
I get this error
Error in py_call_impl(callable, dots$args, dots$keywords) : AttributeError: 'list' object has no attribute 'shape'
Detailed traceback: File "C:\Users\garry\ANACON~1\envs\R-TENS~1\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1779, in fit_generator initial_epoch=initial_epoch) File "C:\Users\garry\ANACON~1\envs\R-TENS~1\lib\site-packages\tensorflow\python\keras\engine\training_generator.py", line 194, in fit_generator batch_size = x[0].shape[0]
I am using Keras 2.2.4.1, tensorflow 1.14.0, reticulate 1.13 and R 3.5.0 on Windows 10 The model looks to have been built OK
Layer (type) Output Shape Param Connected to
input_1 (InputLayer) (None, 1) 0
input_2 (InputLayer) (None, 1) 0
embedding (Embedding) (None, 1, 128) 2560128 input_1[0][0]
input_2[0][0]
flatten (Flatten) (None, 128) 0 embedding[0][0]
flatten_1 (Flatten) (None, 128) 0 embedding[1][0]
dot (Dot) (None, 1) 0 flatten[0][0]
flatten_1[0][0]
dense (Dense) (None, 1) 2 dot[0][0]
Total params: 2,560,130 Trainable params: 2,560,130 Non-trainable params: 0
Any help appreciated. Thanks.