numpy.square - python examples

Here are the examples of the python api numpy.square taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

3 View Complete Implementation : deep_conv_classification_alt31.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [100, 110, 120, 130, 140]:
        for jdraw in [100, 110, 120, 130, 140]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt47.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt48.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt48maxp_luad10_luad10in20_brca10x1.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt49.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt36-sp-cnn.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt48_luad10in20_brca10.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt50.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt48maxp_luad10_luad10in20_brca10x2.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, augs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, augs, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;

3 View Complete Implementation : deep_conv_classification_alt51_luad10in20_brca10.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def multi_win_during_val(val_fn, inputs, targets):
    for idraw in [50, 75, 100, 125, 150]:
        for jdraw in [50, 75, 100, 125, 150]:
            inpt_multiwin = data_aug(inputs, mu, sigma, deterministic=True, idraw=idraw, jdraw=jdraw);
            err_pat, output_pat = val_fn(inpt_multiwin, targets);
            if 'weight' in locals():
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                wei = np.exp(-np.square(dis)/2.0/0.5**2);
                weight += wei;
                err += err_pat * wei;
                output += output_pat * wei;
            else:
                dis = ((idraw/100.0-1.0)**2 + (jdraw/100.0-1.0)**2)**0.5;
                weight = np.exp(-np.square(dis)/2.0/1.0**2);
                err = err_pat * weight;
                output = output_pat * weight;
    return err/weight, output/weight;