Python 3.x 列表中的python self关键字

Python 3.x 列表中的python self关键字,python-3.x,keras,Python 3.x,Keras,我正在阅读一篇关于keras的教程,我发现这个类被另一个类继承了 class LearningRateDecay: def plot(self, epochs, title="Learning Rate Schedule"): lrs = [self(i) for i in epochs] plt.style.use("ggplot") plt.figure() plt.plot(epochs, lrs) plt.title(title)

我正在阅读一篇关于keras的教程,我发现这个类被另一个类继承了

  class LearningRateDecay:
  def plot(self, epochs, title="Learning Rate Schedule"):
    lrs = [self(i) for i in epochs]     
    plt.style.use("ggplot")
    plt.figure()
    plt.plot(epochs, lrs)
    plt.title(title)
    plt.xlabel("Epoch #")
    plt.ylabel("Learning Rate")
其中的时代定义如下:

    N = 100
    epochs = np.arange(0, N)
    a = LearningRateDecay
    a.plot(epochs,"Learning Rate Schedule")
并传递给绘图函数,如下所示:

    N = 100
    epochs = np.arange(0, N)
    a = LearningRateDecay
    a.plot(epochs,"Learning Rate Schedule")
我不明白什么是自我(我)的意思?这是关于访问自我元素还是其他东西? 非常感谢您的帮助。 谢谢

self(i)
指调用一个对象,即使用其
\uuuuuu调用
方法

例如,考虑这个类:

class-MyClass:
定义调用(self,arg):
打印(arg)
def方法(自我):
自我(“测试”)
a=MyClass()
a、 方法()#打印“测试”
a(“其他”)#打印“其他”
在您的示例中,这个类可能有一些定义的行为与
\uuuuu call\uuuuu
相关(它也可以从上层对象继承)。请参阅类文档以了解它。

self(i)
指调用对象,即使用其
\uu调用方法

例如,考虑这个类:

class-MyClass:
定义调用(self,arg):
打印(arg)
def方法(自我):
自我(“测试”)
a=MyClass()
a、 方法()#打印“测试”
a(“其他”)#打印“其他”

在您的示例中,这个类可能有一些定义的行为与
\uuuuu call\uuuuu
相关(它也可以从上层对象继承)。参考课堂文档了解相关信息。

是的,我知道了。谢谢你@Arthur HavlicekYes。我知道了。谢谢你@Arthur Havlicek