파이썬 sum과 같은 Python 요소 별 튜플 연산
어쨌든 다음과 같이 작동하도록 Python에서 튜플 작업을 얻을 수 있습니까? >>> a = (1,2,3) >>> b = (3,2,1) >>> a + b (4,4,4) 대신에: >>> a = (1,2,3) >>> b = (3,2,1) >>> a + b (1,2,3,3,2,1) __ add __ 및 __ mul __ 메소드가 그렇게 작동하도록 정의되어 있기 때문에 그렇게 작동한다는 것을 알고 있습니다. 그래서 유일한 방법은 그것들을 재정의하는 것입니까? 해결 방법 import operator tuple(map(operator.add, a, b)) 참조 페이지 https://stackoverflow.com/questions/497885
2020. 10. 12.
파이썬 Keras 멀티 클래스 모델에서 혼동 행렬 얻기
Keras로 다중 클래스 모델을 구축하고 있습니다. model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']) model.fit(X_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1, callbacks=[checkpoint], validation_data=(X_test, y_test)) # starts training 내 테스트 데이터는 다음과 같습니다 (텍스트 데이터). X_test Out[25]: array([[621, 139, 549, ..., 0, 0, 0], [621, 139, 543, ..., 0, 0, 0]]) y_test Out[2..
2020. 10. 11.