I have implemented the same function dotproduct
once with broadcast
and once without
shared = [1, 2 , 3, 4, 5]
broadcasted = sc.broadcast(shared)
def dotproduct_shared(vector):
return sum([v*w for v,w in zip(vector,shared)])
def dotproduct_broadcast(vector):
return sum([v*w for v,w in zip(vector, broadcasted.value)])
They both work,
the question is: what is the difference ?
Why should I use broadcast ?