94472724eedd3382396d435fe2810422f472967e,tests/embedding.py,,,#,9
Before Change
import torch.nn as nn
from torch.autograd import Variable
sys.path.append("../pytorch2keras")
from converter import pytorch_to_keras
class TestEmbedding(nn.Module):
After Change
return self.embedd(input)
if __name__ == "__main__":
max_error = 0
for i in range(100):
input_np = np.random.randint(0, 10, (1, 1, 4))
input = Variable(torch.LongTensor(input_np))
simple_net = TestEmbedding(1000)
output = simple_net(input)
k_model = pytorch_to_keras(simple_net, input, (1, 4), verbose=True)
pytorch_output = output.data.numpy()
keras_output = k_model.predict(input_np)
error = np.max(pytorch_output - keras_output[0])
print(error)
if max_error < error:
max_error = error
print("Max error: {0}".format(max_error))
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances Project Name: nerox8664/pytorch2keras
Commit Name: 94472724eedd3382396d435fe2810422f472967e
Time: 2018-05-30
Author: nerox8664@gmail.com
File Name: tests/embedding.py
Class Name:
Method Name:
Project Name: OpenNMT/OpenNMT-py
Commit Name: 31f044032f2b7079299ff0656c32dc8123b8d497
Time: 2018-06-12
Author: vince62s@yahoo.com
File Name: onmt/utils/loss.py
Class Name:
Method Name: filter_shard_state
Project Name: nerox8664/pytorch2keras
Commit Name: 94472724eedd3382396d435fe2810422f472967e
Time: 2018-05-30
Author: nerox8664@gmail.com
File Name: tests/squeezenet.py
Class Name:
Method Name: