機械学習で次のエラーが出ます。
/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.6 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
return f(*args, **kwds)
WARNING:tensorflow:From /Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/backend.py:3086: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
WARNING:tensorflow:From /Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/backend.py:1557: calling reduce_mean (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
Traceback (most recent call last):
File "deep2.py", line 33, in <module>
epochs=300)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/models.py", line 920, in fit
validation_steps=validation_steps)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/engine/training.py", line 1592, in fit
batch_size=batch_size)
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/engine/training.py", line 1431, in _standardize_user_data
exception_prefix='input')
File "/Users/idaryuunosuke/.pyenv/versions/anaconda3-5.3.1/envs/py35/lib/python3.5/site-packages/tensorflow/python/keras/_impl/keras/engine/training.py", line 132, in _standardize_input_data
arrays[i] = array
ValueError: could not broadcast input array from shape (2,1) into shape (2)
以下コードです
import tensorflow as tf import tensorflow.contrib.keras as keras from sklearn.model_selection import train_test_split import pandas as pd import numpy as np # データの読み込み --- (*1) analysisresults_data = pd.read_csv("analysis_resultstable_BX.csv",encoding="utf-8") # データをラベルと入力データに分離する y = analysisresults_data.loc[:,["Result"]] x = analysisresults_data.loc[:,["Signatures_id","Hit_count"]] # 学習用とテスト用に分割する --- (*2) x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, train_size = 0.8, shuffle = True) # モデル構造を定義 --- (*3) Dense = keras.layers.Dense model = keras.models.Sequential() model.add(Dense(10, activation='relu', input_shape=(1,))) model.add(Dense(1, activation='sigmoid')) # ---(*3a) # モデルを構築 --- (*4) model.compile( loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) # 学習を実行 --- (*5) model.fit(x_train, y_train, batch_size=20, epochs=300) # モデルを評価 --- (*6) score = model.evaluate(x_test, y_test, verbose=1) print('正解率=', score[1], 'loss=', score[0])
何かわかる方いましたら教えてください。
回答2件
あなたの回答
tips
プレビュー