Git Product home page Git Product logo

deepcollisionalcrosssection's People

Contributors

eugeniavoytik avatar flmeier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

meierlab

deepcollisionalcrosssection's Issues

Cannot create a tensor proto whose content is larger than 2GB

This occurs when running predict.py on large files. I was using a 10,000,000 peptide input file.

I fixed this issue by creating a generator to load the files in batches.

def get_tf_dataset(one_dat, lab, meta_data, data, model_params):
    # XXX reverse the sequences for testing of attention, could probably be done somewhere else, but here it is easy
    reverse = False
    # attention_mask = (one_dat != 22)
    # print(data['lens'].values)
    # attention_mask[:,:,data['lens'].values] = True
    # print(attention_mask)

    if reverse:
        for i, row in enumerate(one_dat):
            no_dum = row[ row != 22]
            no_dum_flip = np.flip(no_dum,0)
            one_dat[i,:len(no_dum)] = no_dum_flip[:, np.newaxis]

    print("preparing data")
    data_chunks = list(np.array_split(one_dat, model_params['batch_size']))
    labels_chunks = list(np.array_split(lab, model_params['batch_size']))
    dm_chunks = list(np.array_split(meta_data, model_params['batch_size']))
    l_chunks = list(np.array_split(data['lens'].values, model_params['batch_size']))
    dtask_chunks = list(np.array_split(data['task'].values, model_params['batch_size']))

    def genenerator():
        for i, j, k, l, m in zip(data_chunks, dm_chunks, labels_chunks, l_chunks, dtask_chunks):
            yield i, j, k, l, m

    print("preparing batched datset")
    dataset_test = tf.data.Dataset.from_generator(genenerator, (tf.float32, tf.float32, tf.float32, tf.float32, tf.float32))
    dataset_test = dataset_test.apply(tf.contrib.data.unbatch())
    dataset_test = dataset_test.batch(model_params['batch_size'])
    dataset_test = dataset_test.prefetch(1) 

    return dataset_test

References:
https://stackoverflow.com/questions/55122902/from-tensor-slices-with-big-numpy-array-while-using-tf-keras
https://stackoverflow.com/questions/49531286/tensorflow-tf-data-dataset-cannot-batch-tensors-with-different-shapes-in-compo

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.