median-research-group / LibMTL

A PyTorch Library for Multi-Task Learning
MIT License
1.89k stars 175 forks source link

MMOE - Replicate the Original paper Chapter 3.2 (Synthetic Data) #68

Closed Steven-1124 closed 4 months ago

Steven-1124 commented 7 months ago

Hi there!

I try hard to replicate the original paper for MMOE Arch while have no idea to get the package run.

Same as the original paper, my data is Synthetic Data like x is a random vector, y1, and y2 are two task vectors generated based on x. I want to reshow Figure 4 in the authors's paper, thus having to calculate loss as well.

Below is how I generate the data:

` def generate_orthogonal_vectors(d): u1 = np.random.rand(d) u1 = u1 / np.linalg.norm(u1) u2 = np.random.rand(d) u2 = u2 - np.dot(u2, u1) * u1 u2 = u2 / np.linalg.norm(u2) return u1, u2

def generate_weight_vectors(u1, u2, c, p): w1 = c u1 w2 = c p * u1 + np.sqrt(1 - p*2) u2 return w1, w2

def generate_labels(data, w, alpha, beta, m, epsilon): y = np.dot(data, w) for i in range(m): y += np.sin(alpha[i] np.dot(data, w) + beta[i]) y += epsilon np.random.randn(len(data)) return y `

The example you posted is more complex data compared to mine and I do not have GPU device. Also, I did not find your main.py

Could you show me how to run the package in Jupiter?

Thanks so much!

Baijiong-Lin commented 4 months ago

We will add it in the future.