我目前正在尝试将 tensorflow 与 R 和 rPython 一起使用,但是在运行会话时出现了一个奇怪的错误。
这里有一个例子:
library(rPython)
python.exec("
import sys
from ctypes import *
sys.argv = ['']
import tensorflow as tf
")
python.exec("
import tflearn
from tflearn.data_utils import to_categorical, pad_sequences
from tflearn.datasets import imdb
train, val, test = imdb.load_data(path='imdb.pkl', maxlen=200,n_words=20000)
trainX, trainY = train
valX, valY = val
testX, testY = test
")
python.exec("
trainX = pad_sequences(trainX, maxlen=200, value=0.)
trainY = to_categorical(trainY, nb_classes=2)
")
# Network building
python.exec("
net = tflearn.input_data([None, 200])
net = tflearn.embedding(net, input_dim=20000, output_dim=128)
net = tflearn.lstm(net, 128)
net = tflearn.dropout(net, 0.5)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam',
loss='categorical_crossentropy')
")
python.exec("
# Training
model = tflearn.DNN(net, clip_gradients=0., tensorboard_verbose=0)
model.fit(trainX, trainY, show_metric=True, batch_size=128)
")
它随机中断执行并显示错误消息����。我只使用 session.run 有一个更大的问题,因为它似乎会立即终止并显示相同的错误消息。当我在另一个示例中使用较小的数据集时。它工作得很好。但这对我来说是不可接受的,有什么错误?