首页 > 解决方案 > 没有名为“ModelWrapper”的模块

问题描述

我正在尝试比较深度学习模型中激活函数的性能,但下面的编码给出了有关 ModelWrapper 的错误。错误如下:“ModuleNotFoundError:没有名为'ModelWrapper'的模块。知道如何处理它。谢谢!

# Activation functions to try
activations = ['relu', 'leaky_relu', 'sigmoid', 'tanh']

# Loop over the activation functions
activation_results = {}


def get_model(act_function):
  if act_function not in ['relu', 'leaky_relu', 'sigmoid', 'tanh']:
    raise ValueError('Make sure your activation functions are named correctly!')
  print("Finishing with",act_function,"...")
  return ModelWrapper(act_function)


for act in activations:
  # Get a new model with the current activation
  model = get_model(act)
  # Fit the model and store the history results
  h_callback = model.fit(X_train, y_train, validation_data=(X_test,y_test), epochs=20, verbose=0)
  activation_results[act] = h_callback
activation_results

标签: wrapper

解决方案


推荐阅读