您能否通过return语句告诉我从上述函数返回的正确方法:return z [key]?
from IPython import display
import pandas as pd
import tensorflow as tf
import numpy as np
import argparse
import sys
global z
z = np.arange(400, 420 + 1)
def try_mapping(key):
# print(key)
# print(key.dtype)
#return key*2
return z[key]
def inputs(data):
keys = tf.map_fn(try_mapping , data)
return keys
def main(unused_argv):
x = np.arange(1, 20 + 1)
df = pd.DataFrame(data={'Key': x})
keys = inputs(df)
with tf.Session() as sess:
print(sess.run(keys))