Giter Site home page Giter Site logo

icml17_knn's Issues

missing functions

it seems that there are some scripts missing in utils.
When trying to execute nntest.py I receive the following:

File "nntest.py", line 2, in
from utils.nn import linearND, linear
ImportError: No module named utils.nn

ValueError: Tried to convert 'indices' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

def linearND(input_, output_size, scope, init_bias=0.0):
shape = input_.get_shape().as_list()
ndim = len(shape)
#print(ndim)
stddev = min(1.0 / math.sqrt(shape[-1]), 0.1)
with tf.variable_scope(scope):
W = tf.get_variable("Matrix", [shape[-1], output_size], tf.float32, tf.random_normal_initializer(stddev=stddev))
X_shape = tf.gather(tf.shape(input_), range(ndim-1))
target_shape = tf.concat(0, [X_shape, [output_size]])
exp_input = tf.reshape(input_, [-1, shape[-1]])
if init_bias is None:
res = tf.matmul(exp_input, W)
else:
with tf.variable_scope(scope):
b = tf.get_variable("bias", [output_size], initializer=tf.constant_initializer(init_bias))
res = tf.matmul(exp_input, W) + b
res = tf.reshape(res, target_shape)
res.set_shape(shape[:-1] + [output_size])
return res

It seems that the line "X_shape = tf.gather(tf.shape(input_), range(ndim-1))" can't work. Could you help me figure it out?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.