Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.
6017 Discussions

TypeError: 'NoneType' object is not subscriptable

Community Manager
System: Ubuntu 16.04 NCSDK version: 2.05 Python version: 3.5.2




I'm running a linear regression example and trying to compile it for the NCS. I've pasted the code below. Tracking it through TensorFlowParser, I see:



  • node.inputs[0].name as x_input:0

  • strip_tensor_id(node.inputs[0].name)) as x_input

  • get_input(strip_tensor_id(node.inputs[0].name))) as None


Thanks for your help!


def model(X, w): return X * w X = tf.placeholder(tf.float64, shape=(None, 1), name="x_input") w = tf.Variable(np.zeros(1), name="weight") pred = model(X, w) if not args["infer"]: num_points = 101 trX = np.float64(np.linspace(-1,1,num_points)).reshape((num_points, 1)) trY = np.float64(2*trX + np.random.randn(*trX.shape) * 0.33).reshape((num_points, 1)) Y = tf.placeholder(tf.float64, shape=(None, 1)) output = tf.identity(pred) cost = tf.reduce_sum(tf.square(Y - pred)) saver = tf.train.Saver(tf.global_variables()) sess = tf.Session() train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost) init = tf.global_variables_initializer() for i in range(100):, feed_dict={X:trX, Y:trY}), '/home/workspace/sandbox/simple_tf_test/lr') print( else: print('Inferring to save') output = tf.identity(pred, name="y_output") saver = tf.train.Saver(tf.global_variables()) sess = tf.Session() global_init = tf.global_variables_initializer() local_init = tf.local_variables_initializer() saver.restore(sess, '/home/workspace/sandbox/simple_tf_test/lr'), '/home/workspace/sandbox/simple_tf_test/lr_graph')
0 Kudos
2 Replies

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:


This error means that you attempted to index an object that doesn't have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. 'NoneType' object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn't define the __getitem__ method . This is a design principle for all mutable data structures in Python.



Nice to see your written post .

Visit here to know more information : typeerror nonetype object is not subscriptable