from __future__ import absolute_import
from . import backend as K


def softmax(x):
    return K.softmax(x)


def softplus(x):
    return K.softplus(x)


def relu(x, alpha=0., max_value=None):
    return K.relu(x, alpha=alpha, max_value=max_value)


def tanh(x):
    return K.tanh(x)


def sigmoid(x):
    return K.sigmoid(x)


def hard_sigmoid(x):
    return K.hard_sigmoid(x)


def linear(x):
    '''
    The function returns the variable that is passed in, so all types work
    '''
    return x


from .utils.generic_utils import get_from_module
def get(identifier):
    return get_from_module(identifier, globals(), 'activation function')

from __future__ import absolute_import
from . import backend as K


def softmax(x):
    ndim = K.ndim(x)
    if ndim == 2:
        return K.softmax(x)
    elif ndim == 3:
        # apply softmax to each timestep
        def step(x, states):
            return K.softmax(x), []
        last_output, outputs, states = K.rnn(step, x, [], masking=False)
        return outputs
    else:
        raise Exception('Cannot apply softmax to a tensor that is not 2D or 3D. ' +
                        'Here, ndim=' + str(ndim))


def softplus(x):
    return K.softplus(x)


def relu(x, alpha=0., max_value=None):
    return K.relu(x, alpha=alpha, max_value=max_value)


def tanh(x):
    return K.tanh(x)


def sigmoid(x):
    return K.sigmoid(x)


def hard_sigmoid(x):
    return K.hard_sigmoid(x)


def linear(x):
    '''
    The function returns the variable that is passed in, so all types work
    '''
    return x


from .utils.generic_utils import get_from_module
def get(identifier):
    return get_from_module(identifier, globals(), 'activation function')

Add support for time-distributed softmax.
Add support for time-distributed softmax.
  from __future__ import absolute_import
  from . import backend as K
  
  
  def softmax(x):
+     ndim = K.ndim(x)
+     if ndim == 2:
-     return K.softmax(x)
+         return K.softmax(x)
+     elif ndim == 3:
+         # apply softmax to each timestep
+         def step(x, states):
+             return K.softmax(x), []
+         last_output, outputs, states = K.rnn(step, x, [], masking=False)
+         return outputs
+     else:
+         raise Exception('Cannot apply softmax to a tensor that is not 2D or 3D. ' +
+                         'Here, ndim=' + str(ndim))
  
  
  def softplus(x):
      return K.softplus(x)
  
  
  def relu(x, alpha=0., max_value=None):
      return K.relu(x, alpha=alpha, max_value=max_value)
  
  
  def tanh(x):
      return K.tanh(x)
  
  
  def sigmoid(x):
      return K.sigmoid(x)
  
  
  def hard_sigmoid(x):
      return K.hard_sigmoid(x)
  
  
  def linear(x):
      '''
      The function returns the variable that is passed in, so all types work
      '''
      return x
  
  
  from .utils.generic_utils import get_from_module
  def get(identifier):
      return get_from_module(identifier, globals(), 'activation function')
  
Add support for time-distributed softmax.
## Code Before:
from __future__ import absolute_import
from . import backend as K


def softmax(x):
    return K.softmax(x)


def softplus(x):
    return K.softplus(x)


def relu(x, alpha=0., max_value=None):
    return K.relu(x, alpha=alpha, max_value=max_value)


def tanh(x):
    return K.tanh(x)


def sigmoid(x):
    return K.sigmoid(x)


def hard_sigmoid(x):
    return K.hard_sigmoid(x)


def linear(x):
    '''
    The function returns the variable that is passed in, so all types work
    '''
    return x


from .utils.generic_utils import get_from_module
def get(identifier):
    return get_from_module(identifier, globals(), 'activation function')

## Instruction:
Add support for time-distributed softmax.
## Code After:
from __future__ import absolute_import
from . import backend as K


def softmax(x):
    ndim = K.ndim(x)
    if ndim == 2:
        return K.softmax(x)
    elif ndim == 3:
        # apply softmax to each timestep
        def step(x, states):
            return K.softmax(x), []
        last_output, outputs, states = K.rnn(step, x, [], masking=False)
        return outputs
    else:
        raise Exception('Cannot apply softmax to a tensor that is not 2D or 3D. ' +
                        'Here, ndim=' + str(ndim))


def softplus(x):
    return K.softplus(x)


def relu(x, alpha=0., max_value=None):
    return K.relu(x, alpha=alpha, max_value=max_value)


def tanh(x):
    return K.tanh(x)


def sigmoid(x):
    return K.sigmoid(x)


def hard_sigmoid(x):
    return K.hard_sigmoid(x)


def linear(x):
    '''
    The function returns the variable that is passed in, so all types work
    '''
    return x


from .utils.generic_utils import get_from_module
def get(identifier):
    return get_from_module(identifier, globals(), 'activation function')
