Skip to content

Instantly share code, notes, and snippets.

@akirayou
Last active February 10, 2018 12:16
Show Gist options
  • Save akirayou/ebf449cfc06dad9735e78a49b9fbc322 to your computer and use it in GitHub Desktop.
Save akirayou/ebf449cfc06dad9735e78a49b9fbc322 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 13 14:07:38 2016
@author: a-noda
"""
import numpy as np
data=np.random.randn(3*10000,1000).astype(np.float32)
y=0
y+=(data[:,20]+0.5)*(data[:,30]-0.4)* (data[:,40]+0.3)
y+=(data[:,50]+0.25)*(data[:,60]-0.15)* (data[:,70]+0.05)
y+=(data[:,80]+0.3)*(data[:,90]-0.2)* (data[:,100]+0.1)
y+=(data[:,110]-0.2)*(data[:,120]+0.1)* (data[:,130]-0.0)
tar=np.zeros(data.shape[0],dtype=np.int32)
tar[np.nonzero(y< 0)[0]]=1
np.savez("sim.npz",inputs=data,tars=tar)
#
#To load sim.npz file do like this.
#
def load(file):
f=np.load(file)
inputs=f['inputs']
inputs=inputs.astype(np.float32)
tars=f['tars'].astype(np.int32)
tidx,=np.nonzero(np.arange(inputs.shape[0])%10 == 0)
lidx,=np.nonzero(np.arange(inputs.shape[0])%10 != 0)
#input data L is for Learn T is for test
Linputs=inputs[lidx,:]
Tinputs=inputs[tidx,:]
#label data L is for Learn T is for test
Ltars=tars[lidx]
Ttars=tars[tidx]
return Linputs,Ltars,Tinputs,Ttars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment