Skip to content

Commit 98e2d56

Browse files
committed
dynaml.tensorflow: Added Tanh activation function
1 parent affec17 commit 98e2d56

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
* */
19+
package io.github.mandar2812.dynaml.tensorflow.layers
20+
21+
import org.platanios.tensorflow.api.learn.Mode
22+
import org.platanios.tensorflow.api.learn.layers.Activation
23+
import org.platanios.tensorflow.api.ops
24+
import org.platanios.tensorflow.api.ops.Output
25+
26+
case class Tanh(override val name: String)
27+
extends Activation(name) {
28+
override val layerType: String = "Sigmoid"
29+
30+
override protected def _forward(input: Output, mode: Mode): Output = {
31+
ops.Math.tanh(input)
32+
}
33+
}

dynaml-core/src/main/scala-2.11/io/github/mandar2812/dynaml/tensorflow/package.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ package object tensorflow {
292292
* */
293293
object dtflearn {
294294

295+
val Tanh: layers.Tanh.type = layers.Tanh
296+
295297
/**
296298
* Constructs a feed-forward layer.
297299
*

0 commit comments

Comments
 (0)