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

Add RepeatVector layer #139

Merged
merged 15 commits into from
Jun 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Made changed requested by avan (see desc.)
- change require message in computeOutputShape
- used inputShape.size(...) for creating shape
- removed author tag
  • Loading branch information
dosier committed Jun 21, 2021
commit af442562873396fbdba1dd1c27d11894688f4ecb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ package org.jetbrains.kotlinx.dl.api.core.layer.reshaping

import org.jetbrains.kotlinx.dl.api.core.KGraph
import org.jetbrains.kotlinx.dl.api.core.layer.Layer
import org.jetbrains.kotlinx.dl.api.core.shape.TensorShape
import org.jetbrains.kotlinx.dl.api.core.shape.toLongArray
import org.tensorflow.Operand
import org.tensorflow.Shape
import org.tensorflow.op.Ops
Expand All @@ -24,7 +22,6 @@ import org.tensorflow.op.Ops
* @property [name] Custom layer name.
* @constructor Creates [RepeatVector] object.
*
* @author Stan van der Bend
* @since 0.3
*/
public class RepeatVector(
Expand All @@ -39,11 +36,10 @@ public class RepeatVector(
override fun build(tf: Ops, kGraph: KGraph, inputShape: Shape): Unit = Unit

override fun computeOutputShape(inputShape: Shape): Shape {
require(inputShape.numDimensions() == 2) { "input tensor must have 2 dimensions" }
val tensorShape = TensorShape(inputShape)
// TODO: maybe make `n` of type Long?
val input = inputShape.toLongArray()
return Shape.make(input[0], n.toLong(), input[1])
require(inputShape.numDimensions() == 2) {
"Input tensor must have 2 dimensions but got ${inputShape.numDimensions()}"
}
return Shape.make(inputShape.size(0), n.toLong(), inputShape.size(1))
}

override fun forward(
Expand Down