text stringlengths 1 93.6k |
|---|
def __exit__(self, *args):
|
self.end = time.time()
|
self.interval = self.end - self.start
|
print("{}: {} s".format(self.msg, self.interval))
|
def pca(X, k=2):
|
X_mean = torch.mean(X,0)
|
X = X - X_mean.expand_as(X)
|
U,S,V = torch.svd(torch.t(X))
|
return torch.mm(X,U[:,:k])
|
def init_args_for_env(parser):
|
env_dict = {
|
'levers': 'Levers-v0',
|
'number_pairs': 'NumberPairs-v0',
|
'predator_prey': 'PredatorPrey-v0',
|
'traffic_junction': 'TrafficJunction-v0',
|
'starcraft': 'StarCraftWrapper-v0'
|
}
|
args = sys.argv
|
env_name = None
|
for index, item in enumerate(args):
|
if item == '--env_name':
|
env_name = args[index + 1]
|
if not env_name or env_name not in env_dict:
|
return
|
import gym
|
import ic3net_envs
|
if env_name == 'starcraft':
|
import gym_starcraft
|
env = gym.make(env_dict[env_name])
|
env.init_args(parser)
|
def display_models(list_models):
|
print('='*100)
|
print('Model log:\n')
|
for model in list_models:
|
print(model)
|
print('='*100 + '\n')
|
# <FILESEP>
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
#
|
# This source code is licensed under the MIT license found in the
|
# LICENSE file in the root directory of this source tree.
|
#
|
# Description: generate inputs and targets for the DLRM benchmark
|
#
|
# Utility function(s) to download and pre-process public data sets
|
# - Criteo Kaggle Display Advertising Challenge Dataset
|
# https://labs.criteo.com/2014/02/kaggle-display-advertising-challenge-dataset
|
# - Criteo Terabyte Dataset
|
# https://labs.criteo.com/2013/12/download-terabyte-click-logs
|
#
|
# After downloading dataset, run:
|
# getCriteoAdData(
|
# datafile="<path-to-train.txt>",
|
# o_filename=kaggleAdDisplayChallenge_processed.npz,
|
# max_ind_range=-1,
|
# sub_sample_rate=0.0,
|
# days=7,
|
# data_split='train',
|
# randomize='total',
|
# criteo_kaggle=True,
|
# memory_map=False
|
# )
|
# getCriteoAdData(
|
# datafile="<path-to-day_{0,...,23}>",
|
# o_filename=terabyte_processed.npz,
|
# max_ind_range=-1,
|
# sub_sample_rate=0.0,
|
# days=24,
|
# data_split='train',
|
# randomize='total',
|
# criteo_kaggle=False,
|
# memory_map=False
|
# )
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
import sys
|
# import os
|
from os import path
|
# import io
|
# from io import StringIO
|
# import collections as coll
|
import numpy as np
|
def convertUStringToDistinctIntsDict(mat, convertDicts, counts):
|
# Converts matrix of unicode strings into distinct integers.
|
#
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.