Fehler in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, : Not compatible with requested type: [type=character; target=double].

Hello,

I am trying to build a neural network model using the data below. However, when I try to build the model, I get the following error message:
Fehler in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, : Not compatible with requested type: [type=character; target=double].

Can you tell me where it results from and what I can do against?

library(mxnet)

training_id <- sample.int(nrow(model_data), size=nrow(model_data)*0.6)
training <- model_data[training_id,]
testing <- model_data[-training_id,]

train_x <- data.matrix(training[,1])
train_y <- data.matrix(training[,-1])

test_x <- data.matrix(testing[,1])
test_y <- data.matrix(testing[-1])

#One-hot encoding to assign one vector per letter for each tweet
input_x <- mx.symbol.Variable("text")
input_y <- mx.symbol.Variable("label")

vocab_size <- 56
number_filters <- 256

#first convolutional layer: 7 x 56 kernel and 256 filters
conv1 <-mx.symbol.Convolution(data=input_x, kernel=c(7,vocab_size), num_filter=number_filters)
relu1 <- mx.symbol.Activation(data=conv1, act_type="relu")
pool1 <- mx.symbol.Pooling(data=relu1, pool_type="max", kernel=c(3,1),stride=c(3,1))

conv2 <-mx.symbol.Convolution(data=input_x, kernel=c(7,vocab_size), num_filter=number_filters)
relu2 <- mx.symbol.Activation(data=conv2, act_type="relu")
pool2 <- mx.symbol.Pooling(data=relu2, pool_type="max", kernel=c(3,1),stride=c(3,1))

conv3 <-mx.symbol.Convolution(data=input_x, kernel=c(7,vocab_size), num_filter=number_filters)
relu3 <- mx.symbol.Activation(data=conv3, act_type="relu")
pool3 <- mx.symbol.Pooling(data=relu3, pool_type="max", kernel=c(3,1),stride=c(3,1))

conv4 <-mx.symbol.Convolution(data=input_x, kernel=c(7,vocab_size), num_filter=number_filters)
relu4 <- mx.symbol.Activation(data=conv4, act_type="relu")
pool4 <- mx.symbol.Pooling(data=relu4, pool_type="max", kernel=c(3,1),stride=c(3,1))

conv5 <-mx.symbol.Convolution(data=input_x, kernel=c(7,vocab_size), num_filter=number_filters)
relu5 <- mx.symbol.Activation(data=conv5, act_type="relu")
pool5 <- mx.symbol.Pooling(data=relu5, pool_type="max", kernel=c(3,1),stride=c(3,1))

conv6 <-mx.symbol.Convolution(data=input_x, kernel=c(7,vocab_size), num_filter=number_filters)
relu6 <- mx.symbol.Activation(data=conv6, act_type="relu")
pool6 <- mx.symbol.Pooling(data=relu6, pool_type="max", kernel=c(3,1),stride=c(3,1))

flatten <- mx.symbol.Flatten(data=pool6)
fc1 <- mx.symbol.FullyConnected(data=flatten, num_hidden=500)
act_fct1 <- mx.symbol.Activation(data=fc1, act_type="relu")
drop1 <- mx.symbol.Dropout(act_fct1, p=0.5)

fc2 <- mx.symbol.FullyConnected(data=flatten, num_hidden=500)
act_fct2 <- mx.symbol.Activation(data=fc2, act_type="relu")
drop2 <- mx.symbol.Dropout(act_fct2, p=0.5)

fc3 <- mx.symbol.FullyConnected(data=drop2, num_hidden=2)
NN_model <- mx.symbol.SoftmaxOutput(data=fc3)

mx.set.seed(100)

model <- mx.model.FeedForward.create(
symbol = NN_model,
X = train_x,
y = train_y,
ctx = devices,
eval.data = list(data=test_x, label=text_y),
num.round = 30,
optimizer = "sgd",
array.batch.size = 100,
array.layout = "rowmajor",
learning.rate = 0.05,
eval.metric = mx.metric.accuracy
)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.