社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

列表中的python self关键字

naser piltan • 5 年前 • 1396 次点击  

我正在阅读一个关于喀拉斯的教程,并来到了一个跨这个班,这是继承了另一个班。

  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")

我不明白什么是 自我(一) 什么意思?这是关于访问自我元素还是其他东西? 非常感谢您的帮助。 谢谢你

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/39398
 
1396 次点击  
文章 [ 1 ]  |  最新文章 5 年前
lesliehuang93
Reply   •   1 楼
lesliehuang93    5 年前

我偷偷来水一下,顺便看看IV能不能插入视频。 下面(可能会)是我这个非常菜的PV随便做的蝴蝶~ 重庆时时彩开奖网北京pk10 视频床是我自建的,完善以后应该会对论坛里的小伙伴们开放~

Arthur Havlicek
Reply   •   2 楼
Arthur Havlicek    5 年前

self(i) 指调用对象,即使用 __call__ 方法。

例如,考虑这个类:

class MyClass:
    def __call__(self, arg):
        print(arg)
    def method(self):
        self('test')

a = MyClass()
a.method()  # Prints 'test'
a('other')  # Prints 'other'

在您的示例中,此类可能具有与 _呼叫__ (也可以从上对象继承)。请参阅课程文档以了解它。