• 大小: 11.44MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-29
  • 语言: Python
  • 标签: python  

资源简介

使用python实现的基于自编码模型的协同过滤推荐算法,运行环境为python2.7+tensorflow,python3.5也可以运行。

资源截图

代码片段和文件信息

‘‘‘ @ Author: wuyi
    @ Date: 2017-7-29
    @ Version: 1.0
‘‘‘

import tensorflow as tf
import time
import numpy as np
import os
import matplotlib
matplotlib.use(‘Agg‘)
import matplotlib.pyplot as plt

class AutoRec():
    ‘‘‘ global variables ‘‘‘
    RMSE_min = 9999.0
    MAE_min = 9999.0
    def __init__(selfsessargs
                 num_usersnum_itemshidden_neuronf_activationg_activation
                 Rating mask_Rating C train_Rating train_mask_Rating test_Rating test_mask_Ratingnum_train_ratingsnum_test_ratings
                 train_epochbatch_sizelearning_rateoptimizer_method
                 display_stepdecay_epoch_steplambda_value
                 user_train_set item_train_set user_test_set item_test_set
                 result_pathdatedata_namemomentum):

        self.sess = sess
        self.args = args

        self.num_users = num_users
        self.num_items = num_items
        self.hidden_neuron = hidden_neuron

        self.Rating = Rating
        self.mask_Rating = mask_Rating
        self.C = C
        self.train_Rating = train_Rating
        self.train_mask_Rating = train_mask_Rating
        self.test_Rating = test_Rating
        self.test_mask_Rating = test_mask_Rating
        self.num_train_ratings = num_train_ratings
        self.num_test_ratings = num_test_ratings

        self.train_epoch = train_epoch
        self.batch_size = batch_size
        self.num_batch = int(self.num_items / float(self.batch_size)) + 1

        self.learning_rate = learning_rate
        self.optimizer_method = optimizer_method
        self.display_step = display_step

        self.f_activation = f_activation
        self.g_activation = g_activation

        self.global_step = tf.Variable(0 trainable=False)
        self.decay_epoch_step = decay_epoch_step
        self.decay_step = self.decay_epoch_step * self.num_batch

        self.lambda_value = lambda_value

        self.train_cost_list = []
        self.test_cost_list = []
        self.test_rmse_list = []
        self.test_mae_list= []

        self.user_train_set = user_train_set
        self.item_train_set = item_train_set
        self.user_test_set = user_test_set
        self.item_test_set = item_test_set

        self.result_path = result_path
        self.date = date
        self.data_name = data_name
        self.momentum = momentum

    def run(self):
        self.model()
        init = tf.global_variables_initializer()
        self.sess.run(init)
        for epoch_itr in xrange(self.train_epoch):
            self.train_model(epoch_itr)
            self.test_model(epoch_itr)
        self.make_records()

    def model(self):
        ‘‘‘ We only construct U-Autoencoder model ‘‘‘
        self.input_Rating = tf.placeholder(dtype=tf.float32 shape=[None self.num_users] name=“input_Rating“)
        self.input_mask_Rating = tf.placeholder(dtype=tf.float32 shape=[None self.num_users] name=“input_mask_Rating“)

        V = tf.get_variable(name=“V“ initia

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      10853  2017-08-03 19:50  AutoencoderRec\AutoRec.py

     文件       8732  2017-08-03 19:06  AutoencoderRec\AutoRec.pyc

     文件     171308  2017-03-24 22:38  AutoencoderRec\data\ml-1m\movies.dat

     文件   24594131  2017-03-24 22:38  AutoencoderRec\data\ml-1m\ratings.dat

     文件       5577  2017-03-24 22:38  AutoencoderRec\data\ml-1m\README

     文件     134368  2017-03-24 22:38  AutoencoderRec\data\ml-1m\users.dat

     文件      17487  2017-07-27 14:58  AutoencoderRec\data\ml-1m-cleaned\item.txt

     文件   24576724  2017-07-27 15:30  AutoencoderRec\data\ml-1m-cleaned\ratings.dat

     文件      29092  2017-07-27 15:00  AutoencoderRec\data\ml-1m-cleaned\user.txt

     文件       1256  2017-08-03 11:16  AutoencoderRec\data_clean.py

     文件       2853  2017-08-03 11:16  AutoencoderRec\data_preprocessor.py

     文件       2289  2017-08-03 19:01  AutoencoderRec\data_preprocessor.pyc

     文件       3464  2017-08-03 19:50  AutoencoderRec\main.py

     文件         76  2017-08-03 10:52  AutoencoderRec\README

     文件        145  2017-07-27 17:51  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11\basic_info.txt

     文件      36347  2017-07-27 17:51  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11\Cost.png

     文件      32362  2017-07-27 17:51  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11\MAE.png

     文件      27556  2017-07-27 17:51  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11\RMSE.png

     文件      18979  2017-07-27 17:51  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11\test_record.txt

     文件       6944  2017-07-27 17:51  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11\train_record.txt

     文件        145  2017-07-27 23:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21\basic_info.txt

     文件      36015  2017-07-27 23:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21\Cost.png

     文件      33318  2017-07-27 23:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21\MAE.png

     文件      26994  2017-07-27 23:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21\RMSE.png

     文件      18971  2017-07-27 23:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21\test_record.txt

     文件       6935  2017-07-27 23:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21\train_record.txt

     文件         96  2017-08-03 19:55  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\overview.txt

     目录          0  2017-08-03 19:52  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501140897.11

     目录          0  2017-08-03 19:52  AutoencoderRec\results\ml-1m-cleaned\2017-07-31\Adam_0.005_1501163088.21

     目录          0  2017-08-03 19:54  AutoencoderRec\results\ml-1m-cleaned\2017-07-31

............此处省略9个文件信息

评论

共有 条评论