質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Keras

Kerasは、TheanoやTensorFlow/CNTK対応のラッパーライブラリです。DeepLearningの数学的部分を短いコードでネットワークとして表現することが可能。DeepLearningの最新手法を迅速に試すことができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

0回答

421閲覧

kerasで学習が終わりません

ruuruusann24

総合スコア16

Keras

Kerasは、TheanoやTensorFlow/CNTK対応のラッパーライブラリです。DeepLearningの数学的部分を短いコードでネットワークとして表現することが可能。DeepLearningの最新手法を迅速に試すことができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2019/01/15 04:05

編集2019/01/15 04:27

https://qiita.com/slowsingle/items/64cc927bb29a49a7af14←こちらのコードを使用しました
http://ai-coordinator.jp/ssd-keras-train
https://qiita.com/slowsingle/items/9006383145a650c84cb0
こちらの記事を参考にして同じことをやっているのですが、途中で学習が止まってしまい、次のエポックへ移行しません。

こちらがterminalの出力です。最後の7/8から進みません。

python

1 2/Users/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py:95: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory. 3 "Converting sparse IndexedSlices to a dense Tensor of unknown shape. " 4Epoch 1/2 57/8 [=========================>....] - ETA: 21s - loss: 6.7430 6

python

1import cv2 2import keras 3from keras.applications.imagenet_utils import preprocess_input 4from keras.backend.tensorflow_backend import set_session 5from keras.models import Model 6from keras.preprocessing import image 7import matplotlib.pyplot as plt 8import numpy as np 9import pickle 10from random import shuffle 11from scipy.misc import imread 12from scipy.misc import imresize 13import tensorflow as tf 14 15from ssd import SSD300 16from ssd_training import MultiboxLoss 17from ssd_utils import BBoxUtility 18 19plt.rcParams['figure.figsize'] = (8, 8) 20plt.rcParams['image.interpolation'] = 'nearest' 21 22np.set_printoptions(suppress=True) 23 24# 21 25NUM_CLASSES = 21 #4 26input_shape = (300, 300, 3) 27 28priors = pickle.load(open('prior_boxes_ssd300.pkl', 'rb')) 29bbox_util = BBoxUtility(NUM_CLASSES, priors) 30 31# gt = pickle.load(open('gt_pascal.pkl', 'rb')) 32gt = pickle.load(open('VOC2007.pkl', 'rb')) 33keys = sorted(gt.keys()) 34num_train = int(round(0.8 * len(keys))) 35train_keys = keys[:num_train] 36val_keys = keys[num_train:] 37num_val = len(val_keys) 38 39##teratailの文字数制限のため省略、省略箇所を確認したい場合はお手数ですが連絡をください 40 41nb_epoch = 2 42history = model.fit_generator(gen.generate(True), gen.train_batches, 43 nb_epoch, verbose=1, 44 callbacks=callbacks, 45 validation_data=gen.generate(False), 46 nb_val_samples=gen.val_batches, 47 nb_worker=1) 48 49inputs = [] 50images = [] 51img_path = path_prefix + sorted(val_keys)[0] 52img = image.load_img(img_path, target_size=(300, 300)) 53img = image.img_to_array(img) 54images.append(imread(img_path)) 55inputs.append(img.copy()) 56inputs = preprocess_input(np.array(inputs)) 57 58preds = model.predict(inputs, batch_size=1, verbose=1) 59results = bbox_util.detection_out(preds) 60 61for i, img in enumerate(images): 62 # Parse the outputs. 63 det_label = results[i][:, 0] 64 det_conf = results[i][:, 1] 65 det_xmin = results[i][:, 2] 66 det_ymin = results[i][:, 3] 67 det_xmax = results[i][:, 4] 68 det_ymax = results[i][:, 5] 69 70 # Get detections with confidence higher than 0.6. 71 top_indices = [i for i, conf in enumerate(det_conf) if conf >= 0.6] 72 73 top_conf = det_conf[top_indices] 74 top_label_indices = det_label[top_indices].tolist() 75 top_xmin = det_xmin[top_indices] 76 top_ymin = det_ymin[top_indices] 77 top_xmax = det_xmax[top_indices] 78 top_ymax = det_ymax[top_indices] 79 80 colors = plt.cm.hsv(np.linspace(0, 1, NUM_CLASSES)).tolist() 81 82 plt.imshow(img / 255.) 83 currentAxis = plt.gca() 84 85 for i in range(top_conf.shape[0]): 86 xmin = int(round(top_xmin[i] * img.shape[1])) 87 ymin = int(round(top_ymin[i] * img.shape[0])) 88 xmax = int(round(top_xmax[i] * img.shape[1])) 89 ymax = int(round(top_ymax[i] * img.shape[0])) 90 score = top_conf[i] 91 label = int(top_label_indices[i]) 92 # label_name = voc_classes[label - 1] 93 display_txt = '{:0.2f}, {}'.format(score, label) 94 coords = (xmin, ymin), xmax-xmin+1, ymax-ymin+1 95 color = colors[label] 96 currentAxis.add_patch(plt.Rectangle(*coords, fill=False, edgecolor=color, linewidth=2)) 97 currentAxis.text(xmin, ymin, display_txt, bbox={'facecolor':color, 'alpha':0.5}) 98 99 plt.show()

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問