Skip to content

Commit

Permalink
Merge pull request #3 from gokceneraslan/master
Browse files Browse the repository at this point in the history
Fixes for Python 3 and TF 1.0
  • Loading branch information
pumpikano authored Jan 23, 2018
2 parents eaee333 + 2f387c0 commit d654b7a
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 97 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ being optimized to account for the changing representations of the training data

## Implementation

This implementation requires Tensorflow>=0.10.
This implementation requires Tensorflow>=1.0.

The Magnet Loss function is implemented in `magnet_ops.py`. The function `magnet_loss` implements the exact
loss function and requires class and cluster labels for each example. This formulation allows varying numbers
Expand Down
2 changes: 1 addition & 1 deletion magnet_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def comparison_mask(a_labels, b_labels):

# Take cluster means within the batch
cluster_examples = tf.dynamic_partition(r, clusters, n_clusters)
cluster_means = tf.pack([tf.reduce_mean(x, 0) for x in cluster_examples])
cluster_means = tf.stack([tf.reduce_mean(x, 0) for x in cluster_examples])

# Compute squared distance of each example to each cluster centroid
sample_costs = tf.squared_difference(cluster_means, tf.expand_dims(r, 1))
Expand Down
1 change: 0 additions & 1 deletion magnet_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def test_magnet_loss():
# Hyperparams
m = 6
d = 4
K = 5

# Sample test data
rdata = rand.random_sample([m*d, 8])
Expand Down
Loading

0 comments on commit d654b7a

Please sign in to comment.