File:Softplus.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 636 × 344 pixels, file size: 20 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Plot of the softplus function and ramp function.
    Date
    Source

    Own work

     
    This vector image includes elements that have been taken or adapted from this file:
     Logit.svg.
    Author Nbarth
    SVG development
    InfoField
     The SVG code is valid.
     This plot was created with Matplotlib.
    Source code
    InfoField

    Python code

    Source code
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.ticker import AutoMinorLocator
    
    fig = plt.figure(figsize=(8, 5))
    ax = fig.add_subplot(111)
    ax.grid(which='major')
    ax.grid(which='minor', linewidth=0.4)
    ax.set_xlim(-3., 3)
    ax.set_ylim(0., 3.)
    ax.set_yticks([0, 1, 2, 3])
    ax.xaxis.set_minor_locator(AutoMinorLocator(2))
    ax.yaxis.set_minor_locator(AutoMinorLocator(2))
    ax.set_aspect('equal')
    
    # Softplus.
    x = np.linspace(-3., 3., 100)
    y = np.log(1. + np.exp(x))
    ax.plot(x, y)
    
    # Ramp, for reference.
    x1 = np.linspace(-3., 0., 50)
    y1 = np.zeros(50)
    ax.plot(x1, y1, linestyle=(0, (5, 5)), color='black')
    xy = np.linspace(0., 3., 50)
    ax.plot(xy, xy, linestyle=(0, (5, 5)), color='black')
    
    cm = 1/2.54
    fig.savefig('softplus.svg', bbox_inches='tight')
    
    # Google Colab
    from google.colab import files
    files.download('softplus.svg')
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    Captions

    Plot of the softplus function and ramp function.

    Items portrayed in this file

    depicts

    16 July 2024

    image/svg+xml

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current04:32, 17 July 2024Thumbnail for version as of 04:32, 17 July 2024636 × 344 (20 KB)wikimediacommons>NbarthUploaded own work with UploadWizard

    There are no pages that use this file.