Ejemplo n.º 1
0
        x = self.pool(F.relu(self.conv2(x)))
        x = self.pool(F.relu(self.conv3(x)))
        x = x.reshape(-1, self.get_features(x))  # 此步必须有
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = F.relu(self.fc3(x))
        return x


if __name__ == '__main__':
    net = Net()
    criterion = nn.CrossEntropyLoss()
    optimizer = optim.SGD(net.parameters(), lr=0.001)
    epochs = 100
    batch_size = 4000
    train_data, train_label = getData.getTrainData()
    t = 0
    while t < 6:
        acc = 0.0
        los = 0.0
        inputs, target = train_data, train_label
        for i in range(batch_size):
            net.zero_grad()
            outputs = net(inputs[i])
            loss = criterion(outputs, target[i].long())
            loss.backward()
            optimizer.step()
            los += loss
            predict = 0
            for j in range(15):
                if outputs[0][j] == max(outputs[0]):
Ejemplo n.º 2
0
				outFile.write(','+str(i))
			outFile.write("\n")

if __name__ == '__main__':
	
	start = time.clock()
	nowtime,lastmonth=getTimes()
	nowtime='2014-5-1'
	lastmonth='2014-4-1'	
	R_Num=8 #推荐职位数
	
	#获取数据	
	allJob_SN=getAllJob_SN(nowtime,lastmonth)#时间段内所有职位
	Jw_SN=getAllJw_SN()#获得所有求职者
	JWINFO,JOB_OFFER=getJWJOBINFO(nowtime,lastmonth)#获得求职者信息及职位信息
	trainData=getTrainData(nowtime,lastmonth)

	getData_time=time.clock()
	print u"getData耗时: %f s" % (getData_time - start)

	#userCF_IIF推荐
	finallyRecommend=userCF_IIF_finallyRecommend(trainData,JWINFO,JOB_OFFER,R_Num)
	userCF_IIF_time=time.clock()
	print u"userCF_IIF耗时: %f s" % (userCF_IIF_time - getData_time)

	#itemCF_IUF推荐
	finallyRecommend=itemCF_IUF_finallyRecommend(trainData,JWINFO,JOB_OFFER,R_Num,finallyRecommend)
	itemCF_IUF_time=time.clock()
	print u"itemCF_IUF耗时: %f s" % (itemCF_IUF_time - userCF_IIF_time)

	#city_type_most_popular推荐
Ejemplo n.º 3
0
            outFile.write("\n")


if __name__ == '__main__':

    start = time.clock()
    nowtime, lastmonth = getTimes()
    nowtime = '2016-7-28'
    lastmonth = '2016-6-1'
    R_Num = 8  #推荐职位数

    #获取数据
    Job_SN = getAllJob_SN(nowtime, lastmonth)  #时间段内所有职位
    Jw_SN = getAllJw_SN()  #获得所有求职者
    JWINFO, JOB_OFFER = getJWJOBINFO(nowtime, lastmonth)  #获得求职者信息及职位信息
    trainData = getTrainData(nowtime, lastmonth)

    getData_time = time.clock()
    print u"getData耗时: %f s" % (getData_time - start)

    #userCF_IIF推荐
    finallyRecommend = userCF_IIF_finallyRecommend(trainData, JWINFO,
                                                   JOB_OFFER, R_Num)
    userCF_IIF_time = time.clock()
    print u"userCF_IIF耗时: %f s" % (userCF_IIF_time - getData_time)

    #itemCF_IUF推荐
    finallyRecommend = itemCF_IUF_finallyRecommend(trainData, JWINFO,
                                                   JOB_OFFER, R_Num,
                                                   finallyRecommend)
    itemCF_IUF_time = time.clock()