【发布时间】:2020-08-06 14:44:42
【问题描述】:
我有一个简单的 python 程序,比如
from collections import defaultdict
import math
x = ["a", "b", "a", "c", "d"]
y = [0.1, 0.2, 0.3, 0.4, 0.5]
z = defaultdict(float)
for i in range(len(x)):
z[x[i]] += y[i]
result = [math.log(z[c]+1) for c in z]
我想将代码重写为 tensorflow,但不知道该怎么做。请帮忙!
【问题讨论】:
标签: python tensorflow collections tensor defaultdict