Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test readability (Layer invoke operator) #145

Open
dosier opened this issue Jun 21, 2021 · 1 comment
Open

Improve test readability (Layer invoke operator) #145

dosier opened this issue Jun 21, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@dosier
Copy link
Contributor

dosier commented Jun 21, 2021

I propose that we create something akin to this (but then as a function of Layer):

    private operator fun RepeatVector.invoke(input: Array<FloatArray>): Output<Float> {
        return Ops.create().let { tf ->
            build(tf, KGraph(Graph().toGraphDef()), Shape.make(10, 10))
            val inputOp = tf.constant(input)
            val isTraining = tf.constant(true)
            val numberOfLosses = tf.constant(1.0f)
            forward(tf, inputOp, isTraining, numberOfLosses).asOutput()
        }
    }

So that we can do this:

        val x = Array(3) { FloatArray(3) { it.toFloat() } }
        val y = layer(x)

Which also nicely matches tests in Keras (the invoke part).

@zaleslaw
Copy link
Collaborator

It's an interesting idea, @dosier , this looks like a special functionality for testing and debugging purposes only, and we have no such functionality. I'm not sure that we should have this in the public API because it creates a separate graph for the layer under the hood.

Currently, the @mkaze is working on the same thing but external to Layer in #103.

But this idea not bad, and probably we could create some invoke extension (like in your example) and make it internal in the tests? Extra-functionality for test purposes in the test module.

After some time of usage, it will be better to understand whether we should open it to the world via Layer API.

@zaleslaw zaleslaw added the enhancement New feature or request label Jun 23, 2021
@zaleslaw zaleslaw added this to the 0.4 milestone Sep 13, 2021
@zaleslaw zaleslaw modified the milestones: 0.4, 0.5 Dec 15, 2021
@ermolenkodev ermolenkodev removed this from the 0.5 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants