Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
766 views
in Technique[技术] by (71.8m points)

deep learning - Why is the method for creating training instances there?

I have the following method get_train_instances this takes a matrix (train_mat), which is a one-hot matrix and consists of users and items, it also takes a number of negative ones (num_negatives), for example 4.

I would like to understand this method in more detail and am therefore looking for an explanation of why this method is run. Are there books, writings, papers, newspaper articles about which I could learn more about why this method should be carried out and what exactly it does?

def get_train_instances(train_mat, num_negatives):
    user_input, item_input, labels = [], [], []
    num_user, num_item = train_mat.shape
    for (u, i) in train_mat.keys():
        user_input.append(u)
        item_input.append(i)
        labels.append(1)
        # negative instances
        for t in range(num_negatives):
            j = np.random.randint(num_item)
            while (u, j) in train_mat.keys():
                j = np.random.randint(num_item)
            user_input.append(u)
            item_input.append(j)
            labels.append(0)
    return user_input, item_input, labels

This method is used in a deep learning neural network. I understood this to mean that this method is used to create training samples so that the model can then improve. However, I am not sure and am therefore looking for a good explanation with a recommendation of a book, paper, newspaper article, ... about which I can learn more about why and how to proceed.

question from:https://stackoverflow.com/questions/65625792/why-is-the-method-for-creating-training-instances-there

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...