So I’m calling my map function like this:

```
test_dataset = test_dataset.map(lambda x: tf.py_function(func=split,
inp=[x]))
```

But i still get the error:

```
AttributeError: 'Tensor' object has no attribute 'numpy'
```

My split function looks like this:

```
def split(data):
# split off intervention
splitteded = tf.split(data, [6, 1], axis=0)
# split into input and target image
splitted = tf.split(splitteded[0], 2, axis=1)
# get intervention over full window
sum = tf.reduce_sum(splitteded[1])
average_intervention = sum.numpy() / np.shape(splitteded[1])[1]
# get average heartrate over full window
peaks, _ = find_peaks([i[0].numpy() for i in tf.split(data, [1, 1, 5], axis=0)[1][0]])
if peaks[0] == 0:
peaks = peaks[1:-1]
start = peaks[0]
end = peaks[-1]
average_heartrate = len(peaks) / ((end - start) / 50)
return (splitted[0], splitted[1], [average_intervention, average_heartrate])
```

Everything I found relating to this says to use tf.py_function since eager execution does not work otherwise inside the dataset map function. But it is still not working for me. I feel I’m missing something very obvious.

Any help is greatly appreciated!