Git Product home page Git Product logo

overpool's Introduction

overpool

Make a 2D pooling layer by walking in half windows over a 2D image (whs:= window half-side). Pooling is the operation of reducing image dimensions in a relevant way, usually for machine learning purposes. The pooling function is arbitrary (see in the "Examples" subsection bellow).

Examples

RGB image test

Function used over every color layer. Parameters used:

whs = 64
pool_func = np.ptp  # (maximum value - minimum value)

RGB image test

2D NetCDF variable test

A 2D NetCDF variable is basically a 2D image of an only channel. It is commonly has too big dimensions, and this code was actually made for dealing with them, in the context of machine learning.

Parameters used:

whs = 512
def pool_func(x):
    try:
        val = np.nanvar(x)
    except:              # if a window is full of NaNs,
        val = np.var(x)  # calculate simple variance
    return(val)

NetCDF image test

One channel image masked pool test

More complex functions can be used for pool_func by using give_window=True as a keyword to overlapping_pool. Here the function created operates at one image considering a mask over it.

Parameters used:

whs = 128
def pool_func(img, window, mask):
    masked = np.ma.masked_array(img,
                    mask=mask[window[0][0]:window[0][1],
                              window[1][0]:window[1][1]])
    try:    result = np.nanmean(masked)
    except: result = np.mean(masked)
    return(result)

One channel image masked pool test

Contact

overpool's People

Contributors

marcosrdac avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.