I'm trying to load into my pipeline several files, each file contains 3 signals and the 3 signals are ordered in 10 minutes intervals. When i load the first file it has this shape (86, 75000,3). I'm using tensorflow 1.14
I have tried the following code, to make the code usable by you i simulate the loading with zeros:
import numpy as np
import tensorflow as tf
def my_func(x):
p = np.zeros([86, 75000, 3])
return p
def load_sign(path):
sign = tf.compat.v1.numpy_function(my_func, [path], tf.float64)
return sign
s = [1, 2] # list with filenames, these are paths, here i simulate with numbers
AUTOTUNE = tf.data.experimental.AUTOTUNE
ds = tf.data.Dataset.from_tensor_slices(s)
ds = ds.map(load_sign, num_parallel_calls=AUTOTUNE)
itera = tf.data.make_one_shot_iterator(ds)
x = itera.get_next()
with tf.Session() as sess:
# sess.run(itera.initializer)
va_sign = sess.run([x])
va = np.array(va_sign)
print(va.shape)
I get this shape: (1, 86, 75000, 3) While i would like to obtain 3 different variables each with this shape: (,75000)
How can i do it? I have also tried this code, but i get an error
import numpy as np
import tensorflow as tf
def my_func(x):
p = np.zeros([86, 75000, 3])
x = p[:,:,0]
y = p[:, :, 1]
z = p[:, :, 2]
return x, y, z
# load the signals, in my example it creates the signals using zeros
def load_sign(path):
a, b, c = tf.compat.v1.numpy_function(my_func, [path], tf.float64)
return tf.data.Dataset.zip((a,b,c))
s = [1, 2] # list with filenames, these are paths, here i simulate with numbers
AUTOTUNE = tf.data.experimental.AUTOTUNE
ds = tf.data.Dataset.from_tensor_slices(s)
ds = ds.map(load_sign, num_parallel_calls=AUTOTUNE)
itera = tf.data.make_one_shot_iterator(ds)
x, y, z = itera.get_next()
with tf.Session() as sess:
# sess.run(itera.initializer)
va_sign = sess.run([x])
va = np.array(va_sign)
print(va.shape)
here i would expect a that x has this shape: (86, 75000), but instead i get this error. How can i make it work? And even better i can obtain an x with this shape (,75000)
TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.