Skip to content

Commit

Permalink
syn
Browse files Browse the repository at this point in the history
  • Loading branch information
zangzelin committed Sep 29, 2020
1 parent 42f3a3d commit 0a392be
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 9 deletions.
Binary file added __pycache__/dataset.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/loss.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/model.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/samples_generator_new.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/utils.cpython-37.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def dsphere(n=100, d=2, r=1, noise=None, ambient=None):

return data

def create_sphere_dataset10000(n_samples=500, d=100, n_spheres=11, r=5, seed=42):
def create_sphere_dataset10000(n_samples=1000, d=100, n_spheres=11, r=5, seed=42):
np.random.seed(seed)

# it seemed that rescaling the shift variance by sqrt of d lets big sphere stay around the inner spheres
Expand Down Expand Up @@ -78,9 +78,9 @@ def create_sphere_dataset10000(n_samples=500, d=100, n_spheres=11, r=5, seed=42)
labels[label_index:label_index + n_sphere_samples] = index
label_index += n_sphere_samples

index_seed = np.linspace(0, 10000, num=20, dtype='int16', endpoint=False)
index_seed = np.linspace(0, 20000, num=20, dtype='int16', endpoint=False)
arr = np.array([], dtype='int16')
for i in range(500):
for i in range(n_samples):
arr = np.concatenate((arr, index_seed+int(i)))
dataset = dataset[arr]
labels = labels[arr]
Expand Down
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def SetParam():
parser.add_argument("-ND", "--N_Dataset", default=800, type=int) # The data number used for training
parser.add_argument("-GC", "--GradualChanging", default=[500, 1000], type=int, nargs='+') # Range for the gradual changing of push-away Loss
parser.add_argument("-R", "--ratio", default=[0.2, 1.0, 0.0, 1.0], type=float, nargs='+') # The weight ratio for loss_ae/loss_iso/loss_angle/loss_push-away
parser.add_argument("-EPS", "--Epsilon", default=0.23, type=float) # The boundary parameters used to determine the neighborhood
parser.add_argument("-EPS", "--Epsilon", default=0.30, type=float) # The boundary parameters used to determine the neighborhood
parser.add_argument("-MK", "--MAEK", default=15, type=int)
parser.add_argument("-E", "--EPOCHS", default=10000, type=int)
parser.add_argument("-P", "--PlotForloop", default=1000, type=int) # Save data and plot every 1000 epochs
Expand All @@ -265,8 +265,8 @@ def SetParam():
args.ParamPath = './param/spheres5500_enc.json'
if args.DATASET == 'Spheres5500' and args.Mode == 'ML-AE':
args.ParamPath = './param/spheres5500_ae.json'
if args.DATASET == 'Spheres10000':
args.ParamPath = './param/spheres10000_ae.json'
if args.DATASET == 'Spheres10000' and args.Mode == 'ML-Enc':
args.ParamPath = './param/spheres10000_enc.json'
if args.ParamPath is not 'None':
jsontxt = open(args.ParamPath, 'r').read()
param = json.loads(jsontxt)
Expand All @@ -282,6 +282,7 @@ def SetParam():
else:
path = "./pic/{}".format(param['name'])

path = path+str(time.time())[:20]
# Save parameters
if not os.path.exists(path):
os.makedirs(path)
Expand Down Expand Up @@ -353,8 +354,8 @@ def Train_MultiRun():
train_data = train_data[:-5500]
train_label = train_label[:-5500]
if param['DATASET'] == 'Spheres10000':
test_data = train_data[9000:]
test_label = train_label[9000:]
test_data = train_data[18500:]
test_label = train_label[18500:]
train_data = train_data[:7500]
train_label = train_label[:7500]

Expand Down
35 changes: 35 additions & 0 deletions param/spheres10000_enc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "MLDL_Spheres5500_N11000_Enc",
"ParamPath": "None",
"Mode": "ML-Enc",
"DATASET": "Spheres10000",
"LEARNINGRATE": 0.001,
"BATCHSIZE": 10000,
"RegularB": 3,
"N_Dataset": 20000,
"GradualChanging": [
200,
400
],
"ratio": [
0.0,
1.0,
0.0,
0.0
],
"Epsilon": 2,
"MAEK": 15,
"EPOCHS": 10000,
"PlotForloop": 1000,
"SEED": 42,
"NetworkStructure": [
101,
90,
80,
70,
2
],
"Noise": 0.0,
"Train_MultiRun": false,
"Visualization": false
}
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, args, model):


# Plotting the results of a single layer in the network based on the input data
def PlotOtherLayer(self, fig, data, label, title='', fig_position0=1, fig_position1=1, fig_position2=1, s=10, dataset='None'):
def PlotOtherLayer(self, fig, data, label, title='', fig_position0=1, fig_position1=1, fig_position2=1, s=1, dataset='None'):

color_list = []
for i in range(label.shape[0]):
Expand Down

0 comments on commit 0a392be

Please sign in to comment.