I hereby claim:
- I am thenerdstation on github.
- I am thenerdstation (https://keybase.io/thenerdstation) on keybase.
- I have a public key whose fingerprint is CA07 4782 93AF 7D53 8A41 85FF 0B19 951B 5876 E550
To claim this, I am signing this object:
tn_model = tf.keras.Sequential( | |
[ | |
tf.keras.Input(shape=(2,)), | |
Dense(1024, activation=tf.nn.relu), | |
# Here use a TN layer instead of the dense layer. | |
TNLayer(), | |
Dense(1, activation=None) | |
] | |
) |
Dense = tf.keras.layers.Dense | |
fc_model = tf.keras.Sequential( | |
[ | |
tf.keras.Input(shape=(2,)), | |
Dense(1024, activation=tf.nn.relu), | |
Dense(1024, activation=tf.nn.relu), | |
Dense(1, activation=None) | |
] | |
) |
import tensorflow as tf | |
import tensornetwork as tn | |
class TNLayer(tf.keras.layers.Layer): | |
def __init__(self): | |
super(TNLayer, self).__init__() | |
# Create the variables for the layer. | |
self.a_var = tf.Variable(tf.random.normal( |
# Old way | |
tn.contractors.greedy(net).get_final_node().tensor | |
# New way! | |
tn.contractors.greedy(set_of_nodes).tensor |
import tensornetwork as tn | |
import numpy as np | |
a = tn.Node(np.eye(2)) | |
b = tn.Node(np.eye(2)) | |
a[0] ^ b[0] # Same as tn.connect(a[0], b[0]) | |
result = a @ b # Same as tn.contract_between(a, b) |
import tensornetwork as tn | |
import numpy as np | |
net = tn.TensorNetwork() | |
a = net.add_node(np.eye(2)) | |
b = net.add_node(np.eye(2)) | |
a[0] ^ b[0] # Same as net.connect(a[0], b[0]) | |
result = a @ b # Same as net.contract_between(a, b) |
import tensorflow as tf | |
tf.enable_v2_behavior() | |
def outer_product(x): | |
return tf.tensordot(x, x, 0) | |
val = tf.ones((1000, 32, 32)) | |
%timeit tf.map_fn(outer_product, val) | |
# >>> 1 loops, best of 3: 849 ms per loop | |
%timeit tf.vectorized_map(outer_product, val) |
I hereby claim:
To claim this, I am signing this object:
pip install mltest |
import mltest | |
import pytest | |
def setup(): | |
mltest.setup() |