예제 #1
0
def index():

    l = {"^IXIC": "NASDAQ", "^NYA": "NYSE", "^XAX": "AMEX"}
    r = []

    for k, v in l.items():
        r1 = getdata.get(k, v)
        r.append(r1)

    cdn_js = CDN.js_files[0]
    cdn_css = CDN.css_files[0]

    return render_template("index.html", r=r, cdn_css=cdn_css, cdn_js=cdn_js)
예제 #2
0
def plot(n):

    # if n == "Google":
    #     a = "GOOG"

    # elif n == "Facebook":
    #     a = "FB"
    # else:
    #      a = "DXC"

    l = {
        "Google": "GOOG",
        "Facebook": "FB",
        "DXC": "DXC",
        "Tesla": "TSLA",
        "Apple": "AAPL",
        "IBM": "IBM",
        "Twitter": "TWTR",
        "Amazon": "AMZN",
        "Microsoft": "MSFT",
        "Dell": "DELL",
        "Cisco": "CSCO",
        "VmWare": "VMW",
        "AMD": "AMD",
        "Intel": "INTC",
        "Dow Jones": "^DJI",
        "NASDAQ": "^IXIC",
        "NYSE": "^NYA",
        "AMEX": "^XAX",
        "Alibaba": "BABA",
        "Addiko Bank": "ADKO.VI"
    }

    a = l[n]

    cdn_js = CDN.js_files[0]
    cdn_css = CDN.css_files[0]

    r1 = getdata.get(a, n)

    return render_template("plot.html",
                           script1=r1[0],
                           div1=r1[1],
                           cdn_css=cdn_css,
                           cdn_js=cdn_js,
                           n1=r1[2],
                           n=n)
예제 #3
0
파일: vgg19.py 프로젝트: hanghang2333/bdimg
    print('ALL DONE')


def makeonehot(X, dim):
    res = []
    for i in X:
        here = np.zeros(dim)
        here[i] = 1
        res.append(here)
    res = np.asarray(res)
    return res


if __name__ == "__main__":
    classnum = 99
    X, Y = getdata.get('/home/lihang/2017/bdimg/data/train_data2/', 224, 224,
                       3)
    X_train, X_test, Y_train, Y_test = train_test_split(X,
                                                        Y,
                                                        train_size=0.93,
                                                        random_state=42)
    Y_train = makeonehot(Y_train, classnum)
    Y_test = makeonehot(Y_test, classnum)
    train(X_train,
          Y_train,
          X_test,
          Y_test,
          depoch=25,
          ftepoch=201,
          batch_size=32,
          classnum=classnum,
          out='2inception.model')
예제 #4
0
sheet.write(0, 7, '公交时间/min')
sheet.write(0, 8, '驾车距离/km')
sheet.write(0, 9, '驾车时间/min')

lists = [[10, 14], [10, 15], [11, 14], [11, 15], [12, 8], [12, 9], [12, 10],
         [12, 11], [12, 12], [12, 13]]
index = 0
line = 1  # 当前待写入待行号

while (index < 10):
    for i in range(nrows):
        for j in range(ncols):
            x = lists[index][0] - 1
            y = lists[index][1] - 1
            if ((i <= 7) and (i >= 3) and (j <= 3) and
                (j >= 0)) or ((i == x) and (j == y)):
                continue
            else:
                sheet.write(line, 0, '%d,%d' % (i + 1, j + 1))  # 出发地
                sheet.write(line, 1, '%d,%d' % (x + 1, y + 1))  # 目的地
                for k in range(4):  # 获取并打印四种出行方式的距离、时间
                    distance, duration = getdata.get(table.cell_value(i, j),
                                                     table.cell_value(x, y), k)
                    sheet.write(line, 2 + k * 2,
                                round(int(distance) / 1000, 1))
                    sheet.write(line, 2 + k * 2 + 1, round(int(duration) / 60))
                line = line + 1
                print(line)
    index = index + 1

wbk.save('data_final.xls')
    def forward(self, x):
        x = self.conv1(x.unsqueeze(1))
        #print(x.size())
        x = self.conv2(x)
        #print(x.size())
        x = x.view(x.size(0), -1)
        x = self.lc1(x)
        #x = self.lc2(x)
        x = self.out(x)
        return x


net = Net().cuda()
print(net)
bsize = 500
log_train, log_test, label_train, label_test = getdata.get()
Train_data = Data.TensorDataset(log_train, label_train)
Test_data = Data.TensorDataset(log_test, label_test)
train_data = Data.DataLoader(dataset=Train_data,
                             batch_size=bsize,
                             shuffle=False)
test_data = Data.DataLoader(dataset=Test_data, batch_size=bsize, shuffle=False)
optimizer = optim.SGD(net.parameters(),
                      lr=0.01,
                      momentum=0.5,
                      weight_decay=1e-9)
loss_function = nn.CrossEntropyLoss()
for epoch in range(1000):

    #print("Epoch: {}".format(epoch))
    running_loss = 0.0
예제 #6
0
파일: train.py 프로젝트: hanghang2333/tfctc
args = parser.parse_args()
np.random.seed(1)  #固定下来随机化shuffle的序列
image_height = 30  #数字图片应该普遍长宽比例是这样
image_width = 120
image_channel = 1
#gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)
# 训练,测试,持久化
#with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_core
config = tf.ConfigProto()
#config.gpu_options.per_process_gpu_memory_fraction = 0.5 # 占用GPU90%的显存
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:
    #with tf.Session() as sess:
    # 完成数据的读取,使用的是tensorflow的读取图片
    X, Y, labellen = getdata.get(image_height, image_width, image_channel)
    print(max(labellen))
    num_class = getdata.classnum() + 1
    print('numclass:', num_class)
    # 将数据集shuffle
    X, Y = util.shuffledata(X, Y)
    # 将数据区分为测试集合和训练集合
    X_train, X_test, Y_train, Y_test = train_test_split(X,
                                                        Y,
                                                        train_size=0.9,
                                                        random_state=33)
    print('Train: ', len(X_train))
    print('Test: ', len(X_test))
    model = MultiNet(image_height, image_width, image_channel, num_class)
    model.train(sess,
                X_train,
예제 #7
0
    print('ALL DONE')


def makeonehot(X, dim):
    res = []
    for i in X:
        here = np.zeros(dim)
        here[i] = 1
        res.append(here)
    res = np.asarray(res)
    return res


if __name__ == "__main__":
    classnum = 99
    X, Y = getdata.get('../data/train_data2/')
    X_train, X_test, Y_train, Y_test = train_test_split(X,
                                                        Y,
                                                        train_size=0.95,
                                                        random_state=79)
    Y_train = makeonehot(Y_train, classnum)
    Y_test = makeonehot(Y_test, classnum)
    train(X_train,
          Y_train,
          X_test,
          Y_test,
          depoch=35,
          ftepoch=50,
          batch_size=32,
          classnum=classnum,
          out='inception.model')
예제 #8
0
    model.save(out)
    # X_test = preprocess_input(X_test)
    #score, acc = model.evaluate(X_test, Y_test, batch_size=batch_size)
    #print('now accu:',acc)
    print('ALL DONE')


def makeonehot(X, dim):
    res = []
    for i in X:
        here = np.zeros(dim)
        here[i] = 1
        res.append(here)
    res = np.asarray(res)
    return res


if __name__ == "__main__":
    X, Y = getdata.get('/home/lihang/2017/bdimg/data/train_data/')
    #X_train, X_test, Y_train, Y_test = train_test_split(X, Y, train_size=0.9, random_state=33)
    Y_train = makeonehot(Y_train, 100)
    #Y_test = makeonehot(Y_test,100)
    train(X,
          Y_train,
          None,
          None,
          epoch=20,
          batch_size=32,
          out='inceptionv3-ft.model')