Try the following snippet. You have to extract the actual lists (which are between parenthesis) that corresponds to your tensors, which are in string
format. So convert this string list to python list using ast
. Then use tf.convert_to_tensor
to convert to a tensor (only if necessary?). If you do want to convert to a tensor, then you have to run the tensor inside a session and get the value and plot. If you do not require to generate a tensor, you can just plot the list without using tensorflow sessions.
import tensorflow as tf
import re
import ast
file = open("test.txt","r")
for line in file:
M_l = re.search(r"Location: (.*)", line)
location = M_l.group(1)
location=ast.literal_eval(re.search('\(([^)]+)', location).group(1))
l=tf.convert_to_tensor(location, dtype=tf.float32)
with tf.Session() as sess:
plt.plot(sess.run(l), 'r+')