I have loaded a model but when doing evaluation using Net.forward() i am getting an error "vector subscript out of range"
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
1 | initial version |
I have loaded a model but when doing evaluation using Net.forward() i am getting an error "vector subscript out of range"
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
I have loaded a model but when doing evaluation using Net.forward() i am getting an error "vector subscript out of range"
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
I have loaded a model but when doing evaluation using Net.forward() i am getting an error "vector the error:
"Vector subscript out of range"range" and an "Initialize openCL runtime" warning
I can access the nets layers and print the names, i have also printed out the Mat img dimensions and they match the input size of the model i created.
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
int main(int argc, char** argv)
{
String modelFile = "graph.pb";
String imageFile = "7img.png";
Net net = readNetFromTensorflow(modelFile);
Mat img = imread(imageFile, IMREAD_GRAYSCALE);
// check if model loaded and print layers
if (net.empty())
{
cout << endl << "net empty" << endl;
exit(0);
...
}
else {
cout << endl << "success" << endl;
vector<String> names = net.getLayerNames();
}
cout << endl << img.cols << " img cols" << endl;
cout << img.rows << " img rows" << endl;
cout << img.channels() << " img channel(s)" << endl;
net.setInput(img);
Mat results = net.forward(); // ERROR HERE
return 0;
}
import tensorflow as tf
import tensorflow.contrib.keras as K
import numpy as np
# Define the model in Keras
model = K.models.Sequential()
model.add(K.layers.Conv2D(32,kernel_size=(3,3),input_shape=(28,28,1)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Conv2D(32,kernel_size=(3,3)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.MaxPooling2D(pool_size=(2,2)))
a,b,c,d = model.output_shape
a = b*c*d
model.add(K.layers.Permute([1, 2, 3])) # Indicate NHWC data layout
model.add(K.layers.Reshape((a,)))
model.add(K.layers.Dense(128))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Dense(10))
model.add(K.layers.Activation('softmax'))
# Get Keras prediction
inp = np.random.standard_normal([1, 28, 28, 1]).astype(np.float32)
tf_out = model.predict(inp)
# Serialize the graph
sess = K.backend.get_session()
constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ['activation_4/Softmax'])
tf.train.write_graph(constant_graph, "", "graphtext.txt", as_text=True)
I have loaded a model but when doing evaluation using Net.forward() i am getting the error: "Vector subscript out of range" and an "Initialize openCL runtime" warning
I can access the nets layers and print the names, i have also printed out the Mat img dimensions and they match the input size of the model i created.
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
int main(int argc, char** argv)
{
String modelFile = "graph.pb";
String imageFile = "7img.png";
Net net = readNetFromTensorflow(modelFile);
Mat img = imread(imageFile, IMREAD_GRAYSCALE);
// check if model loaded and print layers
if (net.empty())
{
cout << endl << "net empty" << endl;
exit(0);
...
}
else {
cout << endl << "success" << endl;
vector<String> names = net.getLayerNames();
}
cout << endl << img.cols << " img cols" << endl;
cout << img.rows << " img rows" << endl;
cout << img.channels() << " img channel(s)" << endl;
net.setInput(img);
Mat results = net.forward(); // ERROR HERE
return 0;
}
import tensorflow as tf
import tensorflow.contrib.keras as K
import numpy as np
# Define the model in Keras
model = K.models.Sequential()
model.add(K.layers.Conv2D(32,kernel_size=(3,3),input_shape=(28,28,1)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Conv2D(32,kernel_size=(3,3)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.MaxPooling2D(pool_size=(2,2)))
a,b,c,d = model.output_shape
a = b*c*d
model.add(K.layers.Permute([1, 2, 3])) # Indicate NHWC data layout
model.add(K.layers.Reshape((a,)))
model.add(K.layers.Dense(128))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Dense(10))
model.add(K.layers.Activation('softmax'))
# Get Keras prediction
inp = np.random.standard_normal([1, 28, 28, 1]).astype(np.float32)
tf_out = model.predict(inp)
# Serialize the graph
sess = K.backend.get_session()
constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ['activation_4/Softmax'])
tf.train.write_graph(constant_graph, "", "graphtext.txt", as_text=True)
I have loaded a model but when doing evaluation using Net.forward() i am getting the error: "Vector subscript out of range" and an "Initialize openCL runtime" warning
I can access the nets layers and print the names, i have also printed out the Mat img dimensions and they match the input size of the model i created.
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
int main(int argc, char** argv)
{
String modelFile = "graph.pb";
String imageFile = "7img.png";
Net net = readNetFromTensorflow(modelFile);
Mat img = imread(imageFile, IMREAD_GRAYSCALE);
// check if model loaded and print layers
if (net.empty())
{
cout << endl << "net empty" << endl;
exit(0);
...
}
else {
cout << endl << "success" << endl;
vector<String> names = net.getLayerNames();
}
cout << endl << img.cols << " img cols" << endl;
cout << img.rows << " img rows" << endl;
cout << img.channels() << " img channel(s)" << endl;
net.setInput(img);
Mat results = net.forward(); // ERROR HERE
return 0;
}
import tensorflow as tf
import tensorflow.contrib.keras as K
import numpy as np
# Define the model in Keras
model = K.models.Sequential()
model.add(K.layers.Conv2D(32,kernel_size=(3,3),input_shape=(28,28,1)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Conv2D(32,kernel_size=(3,3)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.MaxPooling2D(pool_size=(2,2)))
a,b,c,d = model.output_shape
a = b*c*d
model.add(K.layers.Permute([1, 2, 3])) # Indicate NHWC data layout
model.add(K.layers.Reshape((a,)))
model.add(K.layers.Dense(128))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Dense(10))
model.add(K.layers.Activation('softmax'))
# Get Keras prediction
inp = np.random.standard_normal([1, 28, 28, 1]).astype(np.float32)
tf_out = model.predict(inp)
# Serialize the graph
sess = K.backend.get_session()
constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ['activation_4/Softmax'])
tf.train.write_graph(constant_graph, "", "graphtext.txt", as_text=True)
I have loaded a model but when doing evaluation using Net.forward() i am getting the error: "Vector subscript out of range" and an "Initialize openCL runtime" warning
I can access the nets layers and print the names, i have also printed out the Mat img dimensions and they match the input size of the model i created.
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
int main(int argc, char** argv)
{
String modelFile = "graph.pb";
String imageFile = "7img.png";
Net net = readNetFromTensorflow(modelFile);
Mat img = imread(imageFile, IMREAD_GRAYSCALE);
// check if model loaded and print layers
if (net.empty())
{
cout << endl << "net empty" << endl;
exit(0);
...
}
else {
cout << endl << "success" << endl;
vector<String> names = net.getLayerNames();
}
cout << endl << img.cols << " img cols" << endl;
cout << img.rows << " img rows" << endl;
cout << img.channels() << " img channel(s)" << endl;
net.setInput(img);
Mat results = net.forward(); // ERROR HERE
return 0;
}
import tensorflow as tf
import tensorflow.contrib.keras as K
import numpy as np
# Define the model in Keras
model = K.models.Sequential()
model.add(K.layers.Conv2D(32,kernel_size=(3,3),input_shape=(28,28,1)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Conv2D(32,kernel_size=(3,3)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.MaxPooling2D(pool_size=(2,2)))
a,b,c,d = model.output_shape
a = b*c*d
model.add(K.layers.Permute([1, 2, 3])) # Indicate NHWC data layout
model.add(K.layers.Reshape((a,)))
model.add(K.layers.Dense(128))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Dense(10))
model.add(K.layers.Activation('softmax'))
# Get Keras prediction
inp = np.random.standard_normal([1, 28, 28, 1]).astype(np.float32)
tf_out = model.predict(inp)
# Serialize the graph
sess = K.backend.get_session()
constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ['activation_4/Softmax'])
tf.train.write_graph(constant_graph, "", "graphtext.txt", as_text=True)
I have loaded a model but when doing evaluation using Net.forward() i am getting the error: "Vector subscript out of range" and an "Initialize openCL runtime" warning
I can access the nets layers and print the names, i have also printed out the Mat img dimensions and they match the input size of the model i created.
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
int main(int argc, char** argv)
{
String modelFile = "graph.pb";
String imageFile = "7img.png";
Net net = readNetFromTensorflow(modelFile);
Mat img = imread(imageFile, IMREAD_GRAYSCALE);
// check if model loaded and print layers
if (net.empty())
{
cout << endl << "net empty" << endl;
exit(0);
...
}
else {
cout << endl << "success" << endl;
vector<String> names = net.getLayerNames();
}
cout << endl << img.cols << " img cols" << endl;
cout << img.rows << " img rows" << endl;
cout << img.channels() << " img channel(s)" << endl;
net.setInput(img);
Mat results = net.forward(); // ERROR HERE
return 0;
}
import tensorflow as tf
import tensorflow.contrib.keras as K
import numpy as np
# Define the model in Keras
model = K.models.Sequential()
model.add(K.layers.Conv2D(32,kernel_size=(3,3),input_shape=(28,28,1)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Conv2D(32,kernel_size=(3,3)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.MaxPooling2D(pool_size=(2,2)))
a,b,c,d = model.output_shape
a = b*c*d
model.add(K.layers.Permute([1, 2, 3])) # Indicate NHWC data layout
model.add(K.layers.Reshape((a,)))
model.add(K.layers.Dense(128))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Dense(10))
model.add(K.layers.Activation('softmax'))
# Get Keras prediction
inp = np.random.standard_normal([1, 28, 28, 1]).astype(np.float32)
tf_out = model.predict(inp)
# Serialize the graph
sess = K.backend.get_session()
constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ['activation_4/Softmax'])
tf.train.write_graph(constant_graph, "", "graphtext.txt", as_text=True)
I have loaded a model but when doing evaluation using Net.forward() i am getting the error: "Vector subscript out of range" and an "Initialize openCL runtime" warning
I can access the nets layers and print the names, i have also printed out the Mat img dimensions and they match the input size of the model i created.
Any help suggestions to what the error is or how i could solve it would be appreciated. Thank you.
int main(int argc, char** argv)
{
String modelFile = "graph.pb";
String imageFile = "7img.png";
Net net = readNetFromTensorflow(modelFile);
Mat img = imread(imageFile, IMREAD_GRAYSCALE);
// check if model loaded and print layers
if (net.empty())
{
cout << endl << "net empty" << endl;
exit(0);
...
}
else {
cout << endl << "success" << endl;
vector<String> names = net.getLayerNames();
}
cout << endl << img.cols << " img cols" << endl;
cout << img.rows << " img rows" << endl;
cout << img.channels() << " img channel(s)" << endl;
net.setInput(img);
Mat results = net.forward(); // ERROR HERE
return 0;
}
import tensorflow as tf
import tensorflow.contrib.keras as K
import numpy as np
# Define the model in Keras
model = K.models.Sequential()
model.add(K.layers.Conv2D(32,kernel_size=(3,3),input_shape=(28,28,1)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Conv2D(32,kernel_size=(3,3)))
model.add(K.layers.Activation('relu'))
model.add(K.layers.MaxPooling2D(pool_size=(2,2)))
a,b,c,d = model.output_shape
a = b*c*d
model.add(K.layers.Permute([1, 2, 3])) # Indicate NHWC data layout
model.add(K.layers.Reshape((a,)))
model.add(K.layers.Dense(128))
model.add(K.layers.Activation('relu'))
model.add(K.layers.Dense(10))
model.add(K.layers.Activation('softmax'))
# Get Keras prediction
inp = np.random.standard_normal([1, 28, 28, 1]).astype(np.float32)
tf_out = model.predict(inp)
# Serialize the graph
sess = K.backend.get_session()
constant_graph = tf.graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ['activation_4/Softmax'])
tf.train.write_graph(constant_graph, "", "graphtext.txt", as_text=True)